Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

tls.checkServerIdentity throws TypeError: Cannot read property 'CN' of undefined (tls.js:182:37) #9272

Closed
@andiby

Description

@andiby

I have a script that connects to my FTPS server (vsftpd) with a valid TLS certificate.
This script was running with node 0.10.x, but with node 0.12.0 it throws the exception:

tls.js:182
      var commonNames = cert.subject.CN;
                                    ^
TypeError: Cannot read property 'CN' of undefined
    at Object.checkServerIdentity (tls.js:182:37)
    at TLSSocket.<anonymous> (_tls_wrap.js:932:31)
    at TLSSocket.emit (events.js:104:17)
    at TLSSocket._finishInit (_tls_wrap.js:458:8)

My debugging showed me that cert is an empty object.
This object comes from _tls_wrap.js - getPeerCertificate().
The documentation says: "If the peer does not provide a certificate, it returns null or an empty object."
So checkServerIdentity should check if cert has a cert.subject instead of throwing this exception.
And I do not know why cert is an empty object because there should be a valid certificate.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions