【问题标题】:PEM_read_bio_PUBKEY failed while sending signed SAMLRequest to Auth0PEM_read_bio_PUBKEY 在向 Auth0 发送签名的 SAMLRequest 时失败
【发布时间】:2020-08-06 12:17:44
【问题描述】:

我正在尝试签署 (ITfoxtec Identity SAML2) SAMLRequests 并使用 Auth0 进行测试,但在 Auth0 端出现以下错误:

invalid_request:PEM_read_bio_PUBKEY 失败

我在他们的配置中填写了公钥。

{
  "signatureAlgorithm": "rsa-sha256",
  "digestAlgorithm": "sha256",
  "signingCert": "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAqt7eddg/N9MgaivTEWif\n...\nnmEbAFKJtjieiwu1JjsMsdUCAwEAAQ==\n-----END PUBLIC KEY-----\n"
}

这是我生成密钥的方式:

openssl req -x509 -sha256 -newkey rsa:4096 -keyout auth0samlprivate.key -out auth0samlpublic.pem -days 3650 -nodes -subj "/CN=mydomain.com"

# then i generate the public key to fill in the configuration of Auth0
openssl x509 -pubkey -noout -in auth0samlpublic.pem  > auth0samlpublickey.pem

# then I generate the .pfx file to use server side for the private key
openssl pkcs12 -export -out auth0saml.pfx -inkey auth0samlprivate.key -in auth0samlpublic.cer

然后在代码中:

config.SignAuthnRequest = true;
config.SigningCertificate = CertificateUtil.Load("Path/To/auth0saml.pfx", "myPassword");

在浏览器中,我被重定向到包含签名查询参数的正确 URL,因此它似乎被正确处理但 Auth0 似乎无法读取它。

我错过了什么?我是证书部分的新手。

【问题讨论】:

    标签: .net-core certificate auth0 itfoxtec-identity-saml2


    【解决方案1】:

    问题在于生成的证书。

    首先,虽然 Auth0 中的示例使用的是私钥,但使用证书也可以。

    以下命令对我来说很好用:

    openssl req -x509 -sha256 -newkey rsa:2048 -keyout auth0samlprivate.pem -out auth0samlpublic.pem -days 3650 -nodes -subj "/CN=thefiftyapp.com"
    
    openssl pkcs12 -export -in auth0samlpublic.pem -inkey auth0samlprivate.pem -out auth0saml.pfx
    

    我认为真正的问题是在不使用命令行的情况下手动将 pem 文件更改为 cer 文件。

    还有 Auth0 配置:

    {
      "signatureAlgorithm": "rsa-sha256",
      "digestAlgorithm": "sha256",
      "signingCert": "-----BEGIN CERTIFICATE-----\nMIIDFTCCAf2gAwIBAgIUXg1jHZ9qRIrtySCsF/bK2JvYxMQwDQYJKoZIhvcNAQEL\n...\n53f63eKJn9PMmyqIYl9/K48ABR3Bf8exfvK4HRudkSU66pQsj8biIxl4MSDMg/6G\naHUZoTBJbJ/sXmoExGpltvFDcNMITfJMKGFCIBO9VnlsJrXdwalSTpxg/9Yi79GD\n5yMXEjicqion8KE0LMsk93LVS92bkujhSg==\n-----END CERTIFICATE-----\n"
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-12
      • 2018-11-09
      • 2018-09-20
      • 2017-07-06
      • 1970-01-01
      • 2013-09-17
      • 2016-07-17
      • 2019-02-08
      相关资源
      最近更新 更多