Skip to content

[BUG] Single-line privateKey value works OK for (default) HTTP-Redirect, but not for HTTP-POST binding #672

@oliverlockwood

Description

@oliverlockwood

I had SAML working successfully, including signing, with the default HTTP Redirect binding.

Then I made a single change, to set authnRequestBinding to HTTP-POST, and suddenly the system threw an error because of "no start line".

Error: error:0909006C:PEM routines:get_name:no start line
    at Sign.sign (node:internal/crypto/sig:131:29)
    at RSASHA256.getSignature (/opt/my-service/bin/node_modules/xml-crypto/lib/signed-xml.js:128:22)
    at SignedXml.calculateSignatureValue (/opt/my-service/bin/node_modules/xml-crypto/lib/signed-xml.js:469:32)
    at SignedXml.computeSignature (/opt/my-service/bin/node_modules/xml-crypto/lib/signed-xml.js:834:10)
    at signXml (/opt/my-service/bin/node_modules/passport-saml/lib/node-saml/xml.js:107:9)
    at signSamlPost (/opt/my-service/bin/node_modules/passport-saml/lib/node-saml/saml-post-signing.js:8:30)
    at signAuthnRequestPost (/opt/my-service/bin/node_modules/passport-saml/lib/node-saml/saml-post-signing.js:12:12)
    at SAML.generateAuthorizeRequestAsync (/opt/my-service/bin/node_modules/passport-saml/lib/node-saml/saml.js:276:74)
    at SAML.getAuthorizeFormAsync (/opt/my-service/bin/node_modules/passport-saml/lib/node-saml/saml.js:430:36)
    at login-request (/opt/my-service/bin/node_modules/passport-saml/lib/passport-saml/strategy.js:100:59)
    at MultiSamlStrategy.authenticate (/opt/my-service/bin/node_modules/passport-saml/lib/passport-saml/strategy.js:129:13)
    at /opt/my-service/bin/node_modules/passport-saml/lib/passport-saml/multiSamlStrategy.js:28:32
    at PassportSamlConfig.fetchConfig (/opt/my-service/bin/config/passport-saml-config.js:141:16)
    at async Object.getSamlOptions (/opt/my-service/bin/config/passport-saml-config.js:113:50

code: ERR_OSSL_PEM_NO_START_LINE

My passport-saml configuration (with redactions) looks like this:

{
  "callbackUrl": "http://redacted.ourhost.com/login/saml/SSO",
  "protocol": "http://",
  "entryPoint": "https://dev-redacted.oktapreview.com/app/redacted/redacted/sso/saml",
  "issuer": "urn:redacted:redacted:redacted-app",
  "cert": "MIIDpD...REDACTED...qHzQmf",
  "privateKey": "MIIEvQ...REDACTED...gUdJ/qk=",
  "signatureAlgorithm": "sha256",
  "digestAlgorithm": "sha256",
  "maxAssertionAgeMs": 2592000000,
  "authnRequestBinding": "HTTP-POST",
  "logoutUrl": "https://dev-redacted.oktapreview.com/app/redacted/redacted/slo/saml"
}

If I remove authnRequestBinding, it works fine again.
If I keep the authnRequestBinding and contrive my online private key into a multiline one, it works fine again.

I think that either:

  1. this should be fixed, or
  2. at very least, https://github.com/node-saml/passport-saml#security-and-signatures should be updated to say that single-line private keys cannot be used if authnRequestBinding is set to HTTP-POST.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions