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

Add pfx HTTPS option #1364

Merged
merged 25 commits into from Sep 13, 2020
Merged

Conversation

markdboyd
Copy link
Contributor

@markdboyd markdboyd commented Jul 17, 2020

Fixes #1306

Adds support for the pfx option from TLS SecureContextOptions to the HTTPSOptions accepted by got.

I tried to follow the existing convention of passphrase where options.pfx and options.https.pfx are both allowed, but using options.pfx prints a deprecation warning.

I also added a basic test of the deprecation warning. I removed this test because it was failing since I wasn't providing a real PFX fixture. It also wasn't a very meaningful test.

I wasn't sure what other tests to add but I'm happy to add any that are requested.

Checklist

  • I have read the documentation.
  • I have included a pull request description of my changes.
  • I have included some tests.
  • If it's a new feature, I have included documentation updates.

readme.md Outdated Show resolved Hide resolved
source/core/index.ts Outdated Show resolved Hide resolved
@sindresorhus sindresorhus changed the title Add pfx to HTTPS options Add pfx HTTPS option Jul 18, 2020
readme.md Outdated Show resolved Hide resolved
readme.md Outdated Show resolved Hide resolved
readme.md Outdated Show resolved Hide resolved
readme.md Outdated Show resolved Hide resolved
readme.md Outdated Show resolved Hide resolved
source/core/index.ts Outdated Show resolved Hide resolved
markdboyd and others added 6 commits July 21, 2020 09:43
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
@markdboyd
Copy link
Contributor Author

@sindresorhus Thanks for the feedback! I think this is ready for re-review

readme.md Outdated Show resolved Hide resolved
sindresorhus and others added 4 commits July 24, 2020 17:45
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
Copy link
Collaborator

@szmarczak szmarczak left a comment

Choose a reason for hiding this comment

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

@sindresorhus
Copy link
Owner

@markdboyd Friendly bump :)

@markdboyd
Copy link
Contributor Author

Yeah, sorry. I had started to work on adding the requested test, but I was having trouble creating a working PFX fixture using the instructions that @szmarczak linked. I can take another crack at it though

@szmarczak
Copy link
Collaborator

I'll try to do this tomorrow

@Giotino
Copy link
Collaborator

Giotino commented Aug 28, 2020

This PR is missing the "HTTPS options restore" after the request (which has been recently added).

In case of retry a DeprecationWarning is emitted, in order to prevent this you need to add pfx to this section

got/source/core/index.ts

Lines 2391 to 2417 in 38bbb04

// HTTPS options restore
if (options.https) {
if ('rejectUnauthorized' in options.https) {
delete requestOptions.rejectUnauthorized;
}
if (options.https.checkServerIdentity) {
// @ts-expect-error - This one will be removed when we remove the alias.
delete requestOptions.checkServerIdentity;
}
if (options.https.certificateAuthority) {
delete requestOptions.ca;
}
if (options.https.certificate) {
delete requestOptions.cert;
}
if (options.https.key) {
delete requestOptions.key;
}
if (options.https.passphrase) {
delete requestOptions.passphrase;
}
}

Related issue: #1389
Related PR: #1391

@Giotino Giotino mentioned this pull request Aug 31, 2020
6 tasks
@Giotino
Copy link
Collaborator

Giotino commented Aug 31, 2020

Yeah, sorry. I had started to work on adding the requested test, but I was having trouble creating a working PFX fixture using the instructions that @szmarczak linked. I can take another crack at it though

@markdboyd I've set-up in the "HTTPS Tests" PR a test for the PFX option.
13fcbdc (#1430)

Currently it uses the "hidden pfx option" which is deprecated.

@szmarczak szmarczak merged commit c33df7f into sindresorhus:master Sep 13, 2020
@markdboyd
Copy link
Contributor Author

Thanks @Giotino and @szmarczak !

@markdboyd markdboyd deleted the add-https-pfx-option branch September 14, 2020 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better HTTP(S) Request options documentation
4 participants