Skip to content

Add checkServerIdentity to request config for http adapter#2498

Merged
jasonsaayman merged 14 commits intoaxios:release/1.0.0-beta.1from
Annihil:master
Jul 1, 2020
Merged

Add checkServerIdentity to request config for http adapter#2498
jasonsaayman merged 14 commits intoaxios:release/1.0.0-beta.1from
Annihil:master

Conversation

@Annihil
Copy link
Copy Markdown

@Annihil Annihil commented Oct 25, 2019

In order to achieve SSL certificate pinning such a shown here on the NodeJS doc, I added checkServerIdentity to the request option for the nodejs http adapter 🙂

@yasuf
Copy link
Copy Markdown
Collaborator

yasuf commented Oct 28, 2019

can you add documentation and tests for this?

@Annihil
Copy link
Copy Markdown
Author

Annihil commented Oct 29, 2019

All done 👍

Copy link
Copy Markdown
Collaborator

@yasuf yasuf left a comment

Choose a reason for hiding this comment

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

if we can avoid adding ssl-root-cas, that would make me more confident of this change, worst case scenario we add a util in axios instead of ssl-root-cas

const msg = 'Certificate verification error: ' +
`The certificate of '${cert.subject.CN}' ` +
'does not match our pinned fingerprint';
return new Error(msg);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this should be throw new Error I believe?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The correct way seems to be return according to NodeJS' doc

package.json Outdated
"minimist": "^1.2.0",
"mocha": "^5.2.0",
"sinon": "^4.5.0",
"ssl-root-cas": "^1.3.1",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

is there a way to avoid adding this dependency?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I figured out a way, it's gone now

var server, proxy;
var path = require('path');
require('ssl-root-cas')
.inject()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this method is deprecated in this dependency's documentation https://git.coolaj86.com/coolaj86/ssl-root-cas.js#inject, can we use something else?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good catch, ssl-root-cas module is not used anymore anyway

@yasuf
Copy link
Copy Markdown
Collaborator

yasuf commented Nov 4, 2019

also can you add your change to the CHANGELOG.md under a new section, with a title: "Next release:"

@buddhamagnet
Copy link
Copy Markdown

@yasuf @Annihil is this PR progressing? I'd like to be able to use checkServerIdentity in one of my projects without having to switch to the core Node packages.

@kaloudis
Copy link
Copy Markdown

this rules. would love to see this merged

a631807682 and others added 2 commits July 1, 2020 19:14
* fix: remove byte order marker (UTF-8 BOM) when transform response

* fix: remove BOM only utf-8

* test: utf-8 BOM

* fix: incorrect param name

Co-authored-by: Jay <[email protected]>
@jasonsaayman jasonsaayman changed the base branch from master to release/1.0.0-beta.1 July 1, 2020 17:56
@jasonsaayman jasonsaayman added this to the v1.0.0 milestone Jul 1, 2020
@jasonsaayman jasonsaayman merged commit a4b2677 into axios:release/1.0.0-beta.1 Jul 1, 2020
@atlanteh
Copy link
Copy Markdown

Can we please get this into master?

IvanStoilov pushed a commit to IvanStoilov/axios that referenced this pull request Nov 25, 2020
* add checkServerIdentity to request config for http adapter

* add checkServerIdentity unit test

* add checkServerIdentity doc

* add more unit tests for checkServerIdentity

* remove ssl-root-cas dependency

* add changes description to changelog

* Fixing response with utf-8 BOM can not parse to json (axios#2419)

* fix: remove byte order marker (UTF-8 BOM) when transform response

* fix: remove BOM only utf-8

* test: utf-8 BOM

* fix: incorrect param name

Co-authored-by: Jay <[email protected]>

* Update mergeConfig.js

Co-authored-by: Yasu Flores <[email protected]>
Co-authored-by: Cr <[email protected]>
Co-authored-by: Jay <[email protected]>
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.

8 participants