Ich habe eine verschlüsselte SAML 2.0 Antwort/Assertion, die ich entschlüsseln muss. Das Format sieht wie folgt aus:Pass-Saml Lib entschlüsselt nicht korrekt. Entschlüsselt mit einem privaten Entschlüsselungsschlüssel.
<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>
Ich habe auch einen privaten Entschlüsselungsschlüssel mit Format wie folgt aus:
-----BEGIN RSA PRIVATE KEY-----
{mumbo jumbos}
-----END RSA PRIVATE KEY-----
ich versucht habe ONELOGIN SAML Entschlüsselung Tools hier zu entschlüsseln, die verschlüsselte SAML-Assertion (Kopie mit + einfügen zu diesem Eingabefeld), und es funktioniert wie ein Charme. https://www.samltool.com/decrypt.php
Allerdings, wenn ich NodeJS, Pass-saml zu verwenden versucht in die private Schlüsseldatei zu importieren und versuchen, die Antwort zu entschlüsseln, ist es eine „Invalid PEM formated“ bekommt, wenn ich die ("weglassen ----- BEGIN ---- "oder" --- END --- "Banner), oder es wird ein" Ungültiger RSAES-OAEP Padding "Fehler angezeigt.
Dies ist mein Code-Schnipsel:
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.
})
Jede Abhilfe würde geschätzt.
@dlongley was passiert, wenn mein privater Schlüssel im ASCII/UTF8-Format reine Zeichenfolge ist – WABBIT0111