FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

https: throw error if required params missing by kulkarniankita · Pull Request #3064 · nodejs/node · GitHub

/ node Public

https: throw error if required params missing - #3064

Closed
kulkarniankita wants to merge 1 commit into
nodejs:masterfrom
kulkarniankita:master
Closed

kulkarniankita wants to merge 1 commit into
nodejs:masterfrom
kulkarniankita:master

Conversation

Copy link
Copy Markdown

throw Error when required parameters for options in https.createServer are missing

The required parameters of https.createServer is key and cert. When these parameters are not provided by the user then a new Error is thrown for the missing parameter.
A subsequent test is also added to verify the same.

This was discussed in Issue: #3024

cc: @jasnell @mhdawson

thefourtheye added the https Issues and PRs related to the https subsystem. label Sep 25, 2015

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This test only tests cert case. What about key missing case? It would be better if the error messages are checked explicitly.

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Good point. Adding a test case for it as well

jasnell added the semver-major PRs that contain breaking changes and should be released in the next major version. label Sep 25, 2015

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

For this usecase, the callback passed should not be called. So, its better to use assert.fail there.

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I am curious why the callback passed should not be called?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@kulkarniankita Because the point of the test is to throw on invalid cert option.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Style: function(req, res) {

jasnell commented Sep 25, 2015

Copy link
Copy Markdown
Member

Marked as semver-major due to the introduction of the new throw.

Copy link
Copy Markdown
Contributor

@kulkarniankita As this is your first contribution to this project, you might want to go through https://github.com/nodejs/node/blob/master/CONTRIBUTING.md and fix the commit logs :-)

Copy link
Copy Markdown
Author

Because of my issue change, the test-https-pfx.js broke since its asserting on DEPTH_ZERO_SELF_SIGNED_CERT. Should that be fixed to not assert on it anymore and assert on my fix?

srl295 commented Sep 25, 2015

Copy link
Copy Markdown
Member

@kulkarniankita could test-https-pfx.js just set the cert and key parameters to something valid?

Copy link
Copy Markdown
Author

Hi @srl295 yeah adding something valid fixed the test although I am not sure of behaviour change in test-tls-no-cert-required.js as that is failing with the msg that I just added, cert is required there and not provided. There is a comment above that confuses me.

// Omitting the cert or pfx option to tls.createServer() should not throw. // AECDH-NULL-SHA is a no-authentication/no-encryption cipher and hence // doesn't need a certificate. tls.createServer({ ciphers: 'AECDH-NULL-SHA' }).listen(common.PORT, function()

Now this comment means that whenever there is a no-authentication/no-encryption cipher then I should not be asking for a certificate or key. This makes sense so my code should have additional checking for this type of certificate but want to confirm this. (cc: @jasnell )

Copy link
Copy Markdown
Contributor

cc @nodejs/crypto

indutny commented Sep 26, 2015

Copy link
Copy Markdown
Member

What about ciphers without auth? like aNULL or something like this. They don't require cert at all.

jasnell commented Sep 26, 2015

Copy link
Copy Markdown
Member

@indutny... Is there a concise list of known ciphers that do/don't require
cert/key?
On Sep 25, 2015 6:04 PM, "Fedor Indutny" notifications@github.com wrote:

What about ciphers without auth? like aNULL or something like this. They
don't require cert at all.


Reply to this email directly or view it on GitHub
#3064 (comment).

indutny commented Sep 26, 2015

Copy link
Copy Markdown
Member

@jasnell of course!

$ ./out/Release/openssl-cli ciphers -v aNULL
AECDH-AES256-SHA        SSLv3 Kx=ECDH     Au=None Enc=AES(256)  Mac=SHA1
ADH-AES256-GCM-SHA384   TLSv1.2 Kx=DH       Au=None Enc=AESGCM(256) Mac=AEAD
ADH-AES256-SHA256       TLSv1.2 Kx=DH       Au=None Enc=AES(256)  Mac=SHA256
ADH-AES256-SHA          SSLv3 Kx=DH       Au=None Enc=AES(256)  Mac=SHA1
ADH-CAMELLIA256-SHA     SSLv3 Kx=DH       Au=None Enc=Camellia(256) Mac=SHA1
AECDH-AES128-SHA        SSLv3 Kx=ECDH     Au=None Enc=AES(128)  Mac=SHA1
ADH-AES128-GCM-SHA256   TLSv1.2 Kx=DH       Au=None Enc=AESGCM(128) Mac=AEAD
ADH-AES128-SHA256       TLSv1.2 Kx=DH       Au=None Enc=AES(128)  Mac=SHA256
ADH-AES128-SHA          SSLv3 Kx=DH       Au=None Enc=AES(128)  Mac=SHA1
ADH-SEED-SHA            SSLv3 Kx=DH       Au=None Enc=SEED(128) Mac=SHA1
ADH-CAMELLIA128-SHA     SSLv3 Kx=DH       Au=None Enc=Camellia(128) Mac=SHA1
AECDH-RC4-SHA           SSLv3 Kx=ECDH     Au=None Enc=RC4(128)  Mac=SHA1
ADH-RC4-MD5             SSLv3 Kx=DH       Au=None Enc=RC4(128)  Mac=MD5
AECDH-DES-CBC3-SHA      SSLv3 Kx=ECDH     Au=None Enc=3DES(168) Mac=SHA1
ADH-DES-CBC3-SHA        SSLv3 Kx=DH       Au=None Enc=3DES(168) Mac=SHA1
ADH-DES-CBC-SHA         SSLv3 Kx=DH       Au=None Enc=DES(56)   Mac=SHA1
EXP-ADH-DES-CBC-SHA     SSLv3 Kx=DH(512)  Au=None Enc=DES(40)   Mac=SHA1 export
EXP-ADH-RC4-MD5         SSLv3 Kx=DH(512)  Au=None Enc=RC4(40)   Mac=MD5  export
AECDH-NULL-SHA          SSLv3 Kx=ECDH     Au=None Enc=None      Mac=SHA1

indutny commented Sep 26, 2015

Copy link
Copy Markdown
Member

@jasnell I hope you don't suggest hard-coding this?

jasnell commented Sep 26, 2015

Copy link
Copy Markdown
Member

No, I'm just trying to determine if there's some reasonable algorithmic way
to determine if the cert or key are required or not. If not, then we may
just have to punt on doing the check this way
On Sep 25, 2015 6:30 PM, "Fedor Indutny" notifications@github.com wrote:

@jasnell https://github.com/jasnell I hope you don't suggest
hard-coding this?


Reply to this email directly or view it on GitHub
#3064 (comment).

Copy link
Copy Markdown
Contributor

So this behavior is actually the expected behavior. @indutny What about the certificate check? I think that can stay. Right?

indutny commented Sep 26, 2015

Copy link
Copy Markdown
Member

@thefourtheye not really aNULL does not really need neither key nor cert.

Copy link
Copy Markdown
Author

I notice there is a getCiphers method in crypto module. Wondering if anywhere in the existing code, it checks for aNull type of check.

Copy link
Copy Markdown
Contributor

@indutny oh, I wonder how the connection is encrypted and validations happen then.

indutny commented Sep 26, 2015

Copy link
Copy Markdown
Member

@thefourtheye it is using either ephemeral Diffie-Hellman, or not encrypting it at all.

indutny commented Sep 26, 2015

Copy link
Copy Markdown
Member

@kulkarniankita I think we can try iterating through ciphers and checking:

The string returned by SSL_CIPHER_description() in case of success consists of cleartext information separated by one or more blanks in the following sequence:

       <ciphername>
           Textual representation of the cipher name.

       <protocol version>
           Protocol version: SSLv2, SSLv3, TLSv1.2. The TLSv1.0 ciphers are flagged with SSLv3. No new ciphers were added by TLSv1.1.

       Kx=<key exchange>
           Key exchange method: RSA (for export ciphers as RSA(512) or RSA(1024)), DH (for export ciphers as DH(512) or DH(1024)), DH/RSA, DH/DSS, Fortezza.

       Au=<authentication>
           Authentication method: RSA, DSS, DH, None. None is the representation of anonymous ciphers.

       Enc=<symmetric encryption method>
           Encryption method with number of secret bits: DES(40), DES(56), 3DES(168), RC4(40), RC4(56), RC4(64), RC4(128), RC2(40), RC2(56), RC2(128), IDEA(128), Fortezza, None.

       Mac=<message authentication code>
           Message digest: MD5, SHA1.

       <export flag>
           If the cipher is flagged exportable with respect to old US crypto regulations, the word "export" is printed.

If Au=None - cert is not required.

Or, as a simpler fix! We can check if used cipher list is a default one, and throw an error like you do in this PR. This will protect users from most common errors, while keeping the Au=None ciphers work just fine for those who need them.

Comment thread lib/_tls_wrap.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Unnecessary newline.

Copy link
Copy Markdown
Contributor

@indutny Oh... I guess if server and client are not able to come to an agreement about the algorithm to be used, then they ll fall back to any of the null mechanisms. Is that correct?

Apart from that, this patch is not necessary as it is trying to fix something which is actually the expected behavior right? I suppose we can close this then.

@kulkarniankita thanks for the contribution. I am sorry that this patch didnt make it in. Please feel free to discuss further if needed.

Copy link
Copy Markdown
Contributor

Oops sorry. Missed @indutny's suggestions. Reopening now.

thefourtheye reopened this Sep 26, 2015

jasnell commented Oct 26, 2015

Copy link
Copy Markdown
Member

Looks good on initial read but I'd like to get @indutny and @shigeki to take a final look.

shigeki commented Oct 27, 2015

Copy link
Copy Markdown
Contributor

This is bad when option.pfx is used. The PKCS#12 file contains cert and key data so that option.cert and option.key are not needed. That's why the pfx test does not have them. The check should be skipped if it has option.pfx.

Throw an error when required parameters are missing. Handles ciphers that requires no auth.
Does not throw error If pfx option is provided.
Additional tests added for the same.

Fixes: nodejs#3024
PR-URL: nodejs#3064
Comment thread lib/_tls_wrap.js Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

What happens if I want to set the certificate authority for reading only but not the cert/private key.
Example: http://docs.aws.amazon.com/apigateway/latest/developerguide/getting-started-client-side-ssl-authentication.html

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@cbshakumar you mean if cert authority is provided then skip this whole cert/key error handling right?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@kulkarniankita It has been a while since I've looked at this. Should it be possible to set the certificate authority and not set a cert?

jasnell added the stalled Issues and PRs manually marked as stalled and scheduled for automatic closure. label Mar 22, 2016
estliberitas force-pushed the master branch 2 times, most recently from 7da4fd4 to c7066fb Compare April 26, 2016 05:22
rvagg force-pushed the master branch 2 times, most recently from c133999 to 83c7a88 Compare October 18, 2016 17:01

jasnell commented Feb 28, 2017

Copy link
Copy Markdown
Member

Given the lack of forward progress and the uncertainty of what the actual behavior should be, I'm closing. This can be reopened if necessary

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

https Issues and PRs related to the https subsystem. semver-major PRs that contain breaking changes and should be released in the next major version. stalled Issues and PRs manually marked as stalled and scheduled for automatic closure. tls Issues and PRs related to the tls subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.


Back | FazBrowse Home | New Git URL