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

tls requires a subject even when altNames are defined #11771

Closed
CriGoT opened this issue Mar 9, 2017 · 13 comments
Closed

tls requires a subject even when altNames are defined #11771

CriGoT opened this issue Mar 9, 2017 · 13 comments
Labels
tls Issues and PRs related to the tls subsystem.

Comments

@CriGoT
Copy link

CriGoT commented Mar 9, 2017

When using TLS checkServerIdentity is using only subject to determine if a certificate is empty or not

node/lib/tls.js

Line 172 in a2ae089

} else if (subject) {

RFC 5280 allows for a certificate to have only altNames and an empty subject. The existing code already considers altName a priority and uses any supported altNames, if present, instead of the subject.

Although subject empty certificates are not common Windows uses them in their infrastructure so improving this check will simplify integration with systems using certificates with empty subjects.

@mscdex mscdex added the tls Issues and PRs related to the tls subsystem. label Mar 9, 2017
@bnoordhuis
Copy link
Member

The logic in tls.checkServerIdentity() looks okay to me: it only consults the Common Name when no SANs are present. It does however expect that cert.subject is an object.

I think the real bug is in tls.translatePeerCertificate(), it fails to turn .subject into an object when it is an empty string. Possible fix:

diff --git a/lib/_tls_common.js b/lib/_tls_common.js
index 56baf7b..0e06714 100644
--- a/lib/_tls_common.js
+++ b/lib/_tls_common.js
@@ -148,11 +148,11 @@ exports.translatePeerCertificate = function translatePeerCertificate(c) {
   if (!c)
     return null;
 
-  if (c.issuer) c.issuer = tls.parseCertString(c.issuer);
-  if (c.issuerCertificate && c.issuerCertificate !== c) {
+  if (c.issuer != null) c.issuer = tls.parseCertString(c.issuer);
+  if (c.issuerCertificate != null && c.issuerCertificate !== c) {
     c.issuerCertificate = translatePeerCertificate(c.issuerCertificate);
   }
-  if (c.subject) c.subject = tls.parseCertString(c.subject);
+  if (c.subject != null) c.subject = tls.parseCertString(c.subject);
   if (c.infoAccess) {
     var info = c.infoAccess;
     c.infoAccess = {};

cc @indutny since you wrote that code.

CriGoT added a commit to CriGoT/ad-ldap-connector that referenced this issue Mar 30, 2017
Node.js default verification does not consider the possibility of an empty subjects ([issue](nodejs/node#11771)).

In somce cases Windows Active Directory will use certificates with empty subjects, see this [article](https://blogs.technet.microsoft.com/askds/2008/09/16/third-party-application-fails-using-ldap-over-ssl/) for details, making necessary that the connector supports them to use `ldaps`.
This change adds a new configuration option `SSL_ENABLE_EMPTY_SUBJECT` that enables using a patched verification for the server identity that allows using certificates with empty subject. We want to avoid modifying the default behaviour unless required so this flag defaults to `false` and can be enabled when required.
@akdor1154
Copy link

is two months of no activity enough to warrant pinging this?

@indutny
Copy link
Member

indutny commented May 15, 2017

Absolutely good idea to ping us. Thank you 😉

@amellnik
Copy link

Just checking in after a further two months -- is there any plan to meet the RFC or should package owners plan on passing their own authentication function like auth0 did?

@bnoordhuis
Copy link
Member

@indutny The question was more if you think #11771 (comment) is a proper fix.

@amellnik
Copy link

Looking at this further, this actually affects a significant number of packages, and I would recommend that it be treated as a bug. @bnoordhuis -- want to submit your fix as a pull request?

@bnoordhuis
Copy link
Member

I was hoping to get feedback from @indutny but it seems it was not to be. I went ahead and opened #14447.

bnoordhuis added a commit to bnoordhuis/io.js that referenced this issue Jul 25, 2017
Also issuerCertificate but that did not fit on the status line.

Fixes: nodejs#11771
addaleax pushed a commit that referenced this issue Jul 27, 2017
Also issuerCertificate but that did not fit on the status line.

Fixes: #11771
PR-URL: #14473
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
MylesBorins pushed a commit that referenced this issue Sep 19, 2017
Also issuerCertificate but that did not fit on the status line.

Fixes: #11771
PR-URL: #14473
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
@jurjendijkstra
Copy link

Great! This issue has given me headaches. Since this is committed to version 9, which is not LTS yet, would you consider to merge it to version 8?

@jurjendijkstra
Copy link

Nevermind, I see it was already merged, sorry

@jasonmacgowan
Copy link

The fix @bnoordhuis supplied didn't seem to change the behavior to adhere to RFC 5280.

#22906 fixes the issue for me.

@jkinkead
Copy link

This issue should be re-opened, per the last comment.

@MylesBorins
Copy link
Contributor

I'm going to reopen this until #22906 lands

@MylesBorins MylesBorins reopened this Nov 26, 2018
tksugimoto added a commit to tksugimoto/docker-mitm-https-server that referenced this issue Oct 16, 2019
例) Node.js
tls requires a subject even when altNames are defined · Issue #11771 · nodejs/node
nodejs/node#11771
tksugimoto added a commit to tksugimoto/docker-mitm-https-server that referenced this issue Oct 20, 2019
例) Node.js
tls requires a subject even when altNames are defined · Issue #11771 · nodejs/node
nodejs/node#11771
addaleax pushed a commit that referenced this issue Nov 29, 2019
Behavior described in #11771
is still true even though the issue is closed.

This PR is to allow DNS and URI names, even when there is not a subject.

Refs: #11771

PR-URL: #22906
Reviewed-By: James M Snell <jasnell@gmail.com>
addaleax pushed a commit that referenced this issue Nov 30, 2019
Behavior described in #11771
is still true even though the issue is closed.

This PR is to allow DNS and URI names, even when there is not a subject.

Refs: #11771

PR-URL: #22906
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this issue Dec 1, 2019
Behavior described in #11771
is still true even though the issue is closed.

This PR is to allow DNS and URI names, even when there is not a subject.

Refs: #11771

PR-URL: #22906
Reviewed-By: James M Snell <jasnell@gmail.com>
@addaleax
Copy link
Member

I'm going to reopen this until #22906 lands

That has happened now, closing again :)

MylesBorins pushed a commit that referenced this issue Dec 17, 2019
Behavior described in #11771
is still true even though the issue is closed.

This PR is to allow DNS and URI names, even when there is not a subject.

Refs: #11771

PR-URL: #22906
Reviewed-By: James M Snell <jasnell@gmail.com>
richardlau pushed a commit that referenced this issue Jul 1, 2020
Behavior described in #11771
is still true even though the issue is closed.

This PR is to allow DNS and URI names, even when there is not a subject.

Refs: #11771

PR-URL: #22906
Reviewed-By: James M Snell <jasnell@gmail.com>
ckwalsh added a commit to ckwalsh/skooner that referenced this issue Feb 23, 2022
I personally ran issue an issue with a bug in Node TLS handling
(nodejs/node#11771). This bug was fixed in
approximately 12.14.0, and does not show up when I test with v12.22.10,
the latest v12 release at the time of this commit.

(Issue306)[skooner-k8s#306]

Test Plan: Built image locally, deployed to microk8s cluster. No longer
experiencing issue with parsing TLS certs.

Signed-off-by: Cullen Walsh <ckwalsh@cullenwalsh.com>
ckwalsh added a commit to ckwalsh/skooner that referenced this issue Feb 23, 2022
I personally ran issue an issue with a bug in Node TLS handling
(nodejs/node#11771). This bug was fixed in
approximately 12.14.0, and does not show up when I test with v12.22.10,
the latest v12 release at the time of this commit.

skooner-k8s#306

Test Plan: Built image locally, deployed to microk8s cluster. No longer
experiencing issue with parsing TLS certs.

Signed-off-by: Cullen Walsh <ckwalsh@cullenwalsh.com>
abhishekumar-tyagi pushed a commit to abhishekumar-tyagi/node that referenced this issue May 5, 2024
Behavior described in nodejs/node#11771
is still true even though the issue is closed.

This PR is to allow DNS and URI names, even when there is not a subject.

Refs: nodejs/node#11771
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tls Issues and PRs related to the tls subsystem.
Projects
None yet
Development

No branches or pull requests