-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(subject_alt_names): Allow multiple subject_alt_names #34
base: master
Are you sure you want to change the base?
Changes from all commits
8463211
1e7527c
db54c8a
f8c5bae
c06e68f
a50d7b9
1c77d6c
08038ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,8 @@ const debug = createDebug('devcert:certificates'); | |
* individual domain certificates are signed by the devcert root CA (which was | ||
* added to the OS/browser trust stores), they are trusted. | ||
*/ | ||
export default async function generateDomainCertificate(domain: string): Promise<void> { | ||
export default async function generateDomainCertificate(domains: string | string[]): Promise<void> { | ||
const domain = Array.isArray(domains) ? domains[0] : domains; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an example of the kind of code you can simplify if you cast a request for a single domain into an array of length 1 earlier in the process. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea! |
||
mkdirp(pathForDomain(domain)); | ||
|
||
debug(`Generating private key for ${ domain }`); | ||
|
@@ -43,4 +44,4 @@ export function generateKey(filename: string): void { | |
debug(`generateKey: ${ filename }`); | ||
openssl(`genrsa -out "${ filename }" 2048`); | ||
chmod(filename, 400); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,8 +35,9 @@ export interface Options { | |
* are Buffers with the contents of the certificate private key and certificate | ||
* file, respectively | ||
*/ | ||
export async function certificateFor(domain: string, options: Options = {}) { | ||
debug(`Certificate requested for ${ domain }. Skipping certutil install: ${ Boolean(options.skipCertutilInstall) }. Skipping hosts file: ${ Boolean(options.skipHostsFile) }`); | ||
export async function certificateFor(domains: string | string[], options: Options = {}) { | ||
const domain = Array.isArray(domains) ? domains[0] : domains; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I appreciate the backwards-compatibility efforts here. I recommend that you simplify the following code by making -export async function certificateFor(domains: string | string[], options: Options = {}) {
- const domain = Array.isArray(domains) ? domains[0] : domains;
+export async function certificateFor(requestedDomains: string | string[], options: Options = {}) {
+ const domains = Array.isArray(requestedDomains) ? requestedDomains : [requestedDomains] If you do that, you can rename all the other private identifiers to plurals so the code is easier to read, so There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool @zetlen , I thought that too I just wanted to save the backward compatibility. If we're not bothered about backward compatibility (it's really not that big of a deal if we do a major version bump) I'll change this |
||
debug(`Certificate requested for ${ domains }. Skipping certutil install: ${ Boolean(options.skipCertutilInstall) }. Skipping hosts file: ${ Boolean(options.skipHostsFile) }`); | ||
|
||
if (options.ui) { | ||
Object.assign(UI, options.ui); | ||
|
@@ -59,12 +60,18 @@ export async function certificateFor(domain: string, options: Options = {}) { | |
} | ||
|
||
if (!exists(pathForDomain(domain, `certificate.crt`))) { | ||
debug(`Can't find certificate file for ${ domain }, so it must be the first request for ${ domain }. Generating and caching ...`); | ||
await generateDomainCertificate(domain); | ||
debug(`Can't find certificate file for ${ domains }, so it must be the first request for ${ domains }. Generating and caching ...`); | ||
await generateDomainCertificate(domains); | ||
} | ||
|
||
if (!options.skipHostsFile) { | ||
await currentPlatform.addDomainToHostFileIfMissing(domain); | ||
if (Array.isArray(domains)) { | ||
domains.forEach(async (domain) => { | ||
await currentPlatform.addDomainToHostFileIfMissing(domain); | ||
}) | ||
} else { | ||
await currentPlatform.addDomainToHostFileIfMissing(domain); | ||
} | ||
} | ||
|
||
debug(`Returning domain certificate`); | ||
|
@@ -84,4 +91,4 @@ export function configuredDomains() { | |
|
||
export function removeDomain(domain: string) { | ||
return rimraf.sync(pathForDomain(domain)); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,9 @@ | |
"compileOnSave": false, | ||
"compilerOptions": { | ||
"declaration": true, | ||
"lib": [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question as the dependency updates: is it possible to break this into another PR? |
||
"esnext" | ||
], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While running the PR branch, it seems as though this pull request requires upgrades to Node environment, with the usage of functions like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @camsjams if it were me, I'd forego the use of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup, I upgraded it because of |
||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"target": "ES2016", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you find that you needed to update typescript and tslib for your changes to work? If not, I'd like to save dep updates for separate PRs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zetlen yes, at the time I needed to update typescript for
flatMap
to work