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

A pem cert with a trust chain can't be read from a variable #192

Open
coolov opened this issue Aug 21, 2017 · 0 comments
Open

A pem cert with a trust chain can't be read from a variable #192

coolov opened this issue Aug 21, 2017 · 0 comments

Comments

@coolov
Copy link

coolov commented Aug 21, 2017

My pem cert is a trust chain that begins with a subject, like this:

subject=CN=test-client, O=My Company, L=New York, S=New York, C=US
issuer=CN=My Company T3 001 Certificate Authority G1, DC=nyt, DC=net
-----BEGIN CERTIFICATE-----
MIIHRzCCBi+gAwIBAgITYwAAFnfJ+jbV6pZS7gAHAAAWdzANBgkqhkiG9w0BAQsF
...

Everything works well when I pass the cert via a file path, e.g.:

{
    cert: './client.pem',
    key: './client.key'
 }

But if I pass the cert via a variable it crashes the app:

{
    cert: CLIENT_CERT,  // contains a pem cert with a subject as the first line
    key: CLIENT_KEY
 }

The reason is that the line testing if the variable contains the cert and not a path to the cert evaluates to false. The given cert does not start with -----BEGIN, but with subject=, so this test does not pass:
!/^-----BEGIN/.test(self.options.ssl.cert.toString('utf8'))

Instead of treating the string as a cert, it erroneously treats it as a file path and attempts to use it to load the cert from disk.

@coolov coolov changed the title A pem cert with distinguished name parameters can't be read from a variable A pem cert with a subject can't be read from a variable Aug 22, 2017
@coolov coolov changed the title A pem cert with a subject can't be read from a variable A pem cert with multiple subjects can't be read from a variable Aug 24, 2017
@coolov coolov changed the title A pem cert with multiple subjects can't be read from a variable A pem cert with a trust chain can't be read from a variable Aug 24, 2017
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

No branches or pull requests

1 participant