Tag: onelogin

passport-saml lib不能正确解密带有私钥解密密钥的saml EncryptedAssertion

我有一个encryption的SAML 2.0响应/断言,我需要解密。 格式如下所示: <saml:EncryptedAssertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"> <xenc:EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"> <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"/> <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> <xenc:EncryptedKey> <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"/> <xenc:CipherData> <xenc:CipherValue>{some ciphers}</xenc:CipherValue> </xenc:CipherData> </xenc:EncryptedKey> </ds:KeyInfo> <xenc:CipherData> <xenc:CipherValue>{assertion body}</xenc:CipherValue> </xenc:CipherData> </xenc:EncryptedData> </saml:EncryptedAssertion> 我也有这样的格式的私人解密密钥: —–BEGIN RSA PRIVATE KEY—– {mumbo jumbos} —–END RSA PRIVATE KEY—– 我已经尝试在这里使用OneLogin的saml解密工具来解密encryption的SAML断言(复制并粘贴到该input框),它就像一个魅力。 https://www.samltool.com/decrypt.php 但是,当我试图使用nodejs,passport-saml导入私钥文件并尝试解密响应时,如果我省略(“—– BEGIN —-”),则会得到“Invalid PEM formated”或“— END —”标题),或者得到“无效的RSAES-OAEP填充”错误。 这是我的代码片段: const fs = require('fs'); const Promise = […]