2017-04-19 6 views
1

私は復号化する必要がある暗号化されたSAML 2.0応答/アサーションを持っています。私は暗号化されたSAMLアサーションを復号化するために、ここでOneLoginのSAML復号化ツールを使用してみましたがpassport-saml libはsamlを正しく復号化しません。秘密の復号鍵を使用したEncryptedAssertion

-----BEGIN RSA PRIVATE KEY----- 
{mumbo jumbos} 
-----END RSA PRIVATE KEY----- 

(コピー+:私もこのような形式の秘密復号鍵を持っている

<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> 

:フォーマットは次のようになりますその入力ボックスにペーストしてください)、それは魅力のように機能します。私はプライベートキーファイルをインポートし、応答を解読しようとするパスポート、SAML、nodejsを使用しようとしたとき、私は( "-----省略した場合しかし、それは「無効なPEMがフォーマットさ」を取得します https://www.samltool.com/decrypt.php

BEGIN ---- "または" --- END --- "バナー)、または「無効なRSAES-OAEPパディング」エラーが発生します。

これは私のコードスニペットです:

const fs = require('fs'); 
const Promise = require('bluebird'); 
const path = require('path'); 
const forge = require('node-forge'); 
let pkey = fs.readFileSync(path.join(__dirname,'./myTestKey.pem'), 'utf8'); 
//let testKey = new Buffer(pkey).toString('base64'); 
let SAML = require('passport-saml/lib/passport-saml/saml.js'); 
let saml = new SAML({...,decryptionPvk: pkey }); 
let validatePostResponseAsync = Promise.promisify(saml.validatePostResponse); 

validatePostResponseAsync(myResponse, pkey) 
.then(response=>{ 
}) 
.catch(error=>{ 
// it always throw error of the 2 mentioned above. 
}) 

どれ回避策がいただければ幸いです。

+0

@dlongley私の秘密鍵がASCII/UTF8形式の純粋な文字列の場合 – WABBIT0111

答えて

2

私はそれを理解したと思います。同様の問題で苦労している人には、---BEGIN RSA PRIVATE KEY------END RSA PRIVATE KEY---を含める必要があります。バナーが含まれていない場合、passport-saml libが依存するノード・フォージ・ライブラリーはエラーをスローします。

関連する問題