Skip to content

Commit

Permalink
feat: Changes for PKI support - #2694 (#15179)
Browse files Browse the repository at this point in the history
Co-authored-by: GCHQDeveloper911 <[email protected]>
Co-authored-by: Jennifer Shehane <[email protected]>
Co-authored-by: Zach Bloomquist <[email protected]>
Co-authored-by: Zach Bloomquist <[email protected]>
  • Loading branch information
5 people authored Jul 12, 2021
1 parent cf4ccb2 commit 2975990
Show file tree
Hide file tree
Showing 11 changed files with 1,723 additions and 8 deletions.
72 changes: 71 additions & 1 deletion cli/schema/cypress.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,76 @@
"type": "boolean",
"default": false,
"description": "Enables including elements within the shadow DOM when using querying commands (e.g. cy.get(), cy.find()). Can be set globally in cypress.json, per-suite or per-test in the test configuration object, or programmatically with Cypress.config()"
},
"clientCertificates": {
"description": "Defines client certificates to use when sending requests to the specified URLs",
"type": "array",
"items": {
"type": "object",
"properties": {
"url": {
"description": "Requests for URLs matching this minimatch pattern will use the supplied client certificate",
"type": "string"
},
"ca": {
"description": "Path(s) to CA file(s) to validate certs against, relative to project root",
"type": "array",
"items": {
"type": "string"
}
},
"certs": {
"type": "array",
"items": {
"anyOf": [
{
"description": "PEM file specific properties",
"type": "object",
"properties": {
"cert": {
"description": "Path to the certificate, relative to project root",
"type": "string"
},
"key": {
"description": "Path to the private key, relative to project root",
"type": "string"
},
"passphrase": {
"description": "(Optional) File path to a UTF-8 text file containing the passphrase for the key, relative to project root",
"type": "string"
}
},
"required": [
"cert",
"key"
]
},
{
"description": "PFX file specific properties",
"type": "object",
"properties": {
"pfx": {
"description": "Path to the certificate container, relative to project root",
"type": "string"
},
"passphrase": {
"description": "(Optional) File path to a UTF-8 text file containing the passphrase for the container, relative to project root",
"type": "string"
}
},
"required": [
"pfx"
]
}
]
}
}
},
"required": [
"url",
"certs"
]
}
}
}
}
Expand All @@ -299,4 +369,4 @@
}
}
]
}
}
9 changes: 7 additions & 2 deletions packages/network/lib/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ import { getProxyForUrl } from 'proxy-from-env'
import url from 'url'
import { createRetryingSocket, getAddress } from './connect'
import { lenientOptions } from './http-utils'
import { ClientCertificateStore } from './client-certificates'

const debug = debugModule('cypress:network:agent')
const CRLF = '\r\n'
const statusCodeRe = /^HTTP\/1.[01] (\d*)/

export const clientCertificateStore = new ClientCertificateStore()

type WithProxyOpts<RequestOptions> = RequestOptions & {
proxy: string
shouldRetry?: boolean
Expand Down Expand Up @@ -49,8 +52,8 @@ interface CreateProxySockOpts {
type CreateProxySockCb = (
(err: undefined, result: net.Socket, triggerRetry: (err: Error) => void) => void
) & (
(err: Error) => void
)
(err: Error) => void
)

export const createProxySock = (opts: CreateProxySockOpts, cb: CreateProxySockCb) => {
if (opts.proxy.protocol !== 'https:' && opts.proxy.protocol !== 'http:') {
Expand Down Expand Up @@ -190,6 +193,8 @@ export class CombinedAgent {
debug('got family %o', _.pick(options, 'family', 'href'))

if (isHttps) {
_.assign(options, clientCertificateStore.getClientCertificateAgentOptionsForUrl(options.uri))

return this.httpsAgent.addRequest(req, options)
}

Expand Down
Loading

4 comments on commit 2975990

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 2975990 Jul 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/7.8.0/circle-develop-297599071c274c85785ccb4872b816fbd29c93b9/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 2975990 Jul 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 ia32 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/7.8.0/appveyor-develop-297599071c274c85785ccb4872b816fbd29c93b9/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 2975990 Jul 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/7.8.0/appveyor-develop-297599071c274c85785ccb4872b816fbd29c93b9/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 2975990 Jul 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/7.8.0/circle-develop-297599071c274c85785ccb4872b816fbd29c93b9/cypress.tgz

Please sign in to comment.