Skip to content
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: support scoped client certificates #7626

Merged
merged 18 commits into from
Feb 14, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
style: fix unknown word
  • Loading branch information
nachoaldamav committed Feb 7, 2024
commit 5b01af92ec16eb81c783673f9b6a98ca9c44c38b
14 changes: 7 additions & 7 deletions network/fetch/src/fetchFromRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export type { AgentOptions }

function getUserCertificates (authOptions: Record<string, string>) {
// Get all the auth options that have :certfile or :keyfile in their name
const certAuths: {
const clientCerts: {
[registry: string]: {
ca?: string
cert: string
Expand All @@ -44,21 +44,21 @@ function getUserCertificates (authOptions: Record<string, string>) {
if (key.includes(':certfile') || key.includes(':keyfile') || key.includes(':cafile')) {
// Split by '/:' because the registry may contain a port
const registry = key.split('/:')[0] + '/'
if (!certAuths[registry]) {
certAuths[registry] = { cert: '', key: '' }
if (!clientCerts[registry]) {
clientCerts[registry] = { cert: '', key: '' }
}

if (key.includes(':certfile')) {
certAuths[registry].cert = readFileSync(value, 'utf8')
clientCerts[registry].cert = readFileSync(value, 'utf8')
} else if (key.includes(':keyfile')) {
certAuths[registry].key = readFileSync(value, 'utf8')
clientCerts[registry].key = readFileSync(value, 'utf8')
} else if (key.includes(':cafile')) {
certAuths[registry].ca = readFileSync(value, 'utf8')
clientCerts[registry].ca = readFileSync(value, 'utf8')
}
}
}

return certAuths
return clientCerts
}

export function createFetchFromRegistry (
Expand Down