मैंने इस मुद्दे के बारे में अन्य पोस्टों को देखा है और उनमें से कोई भी मेरी स्थिति को संबोधित नहीं कर रहा है।साइनएडएक्सएमएल चेकसिग्नेचर झूठी
मैं पिछले सप्ताह के लिए एक saml कथन की पुष्टि करने की कोशिश कर दिया गया है और मैं 2 ग्राहकों है कि मुझे SAML भेज दिया है, लेकिन मैं इसे सत्यापित नहीं कर सकता।
मुख्य प्रक्रिया हम एक बेस 64 इनकोडिंग जोर मिलता है और मैं इसे डिकोड है। PreserveWhitespace = true के साथ इसे XmlDocment में लोड करें।
को सत्यापित विधि
public static bool Verify(X509Certificate2 cert, XmlElement xmlElement, SignedXml signedXml)
{
bool flag;
try
{
KeyInfo keyInfo = new KeyInfo();
var clause = new KeyInfoX509Data(cert);
keyInfo.AddClause(clause);
XmlElement signatureElement = GetSignatureElement(xmlElement);
if (signatureElement == null)
{
string message = "The XML does not contain a signature.";
throw new SAMLSignatureException(message);
}
signedXml.LoadXml(signatureElement);
if (keyInfo != null)
{
signedXml.KeyInfo = keyInfo;
}
SetSigningKeyFromKeyInfo(signedXml);
flag = signedXml.CheckSignature(cert.PublicKey.Key);
}
catch (Exception exception)
{
throw new SAMLSignatureException("Failed to verify the XML signature.", exception);
}
return flag;
}
private static void SetSigningKeyFromKeyInfo(SignedXml signedXml)
{
IEnumerator enumerator = signedXml.KeyInfo.GetEnumerator();
while (enumerator.MoveNext())
{
if (enumerator.Current is KeyInfoX509Data)
{
var current = (KeyInfoX509Data) enumerator.Current;
if (current.Certificates.Count != 0)
{
var certificate = (X509Certificate) current.Certificates[0];
var certificate2 = new X509Certificate2(certificate);
AsymmetricAlgorithm key = certificate2.PublicKey.Key;
signedXml.SigningKey = key;
return;
}
}
else
{
if (enumerator.Current is RSAKeyValue)
{
var value2 = (RSAKeyValue) enumerator.Current;
signedXml.SigningKey = value2.Key;
return;
}
if (enumerator.Current is DSAKeyValue)
{
var value3 = (DSAKeyValue) enumerator.Current;
signedXml.SigningKey = value3.Key;
return;
}
}
}
throw new SAMLSignatureException("No signing key could be found in the key info.");
}
मैं ग्राहक है कि मैं Web.Config (अपने संग्रहीत के रूप में बेस 64 इनकोडिंग स्ट्रिंग) XmlElement पर हस्ताक्षर किए तत्व है से पढ़ने से प्रमाण पत्र है, signedXml एक SignedXml वस्तु है कि नई SignedXml (XmlElement)
दोनों ग्राहकों झूठी checksignature द्वारा वापस मिलता है लेकिन जब मैं अपने प्रमाण पत्र के साथ अपने ही हस्ताक्षर किए saml बनाने यह सच वापस आ जाएगी साथ बनाया गया था।
मुझे यहां क्या याद आ रही है?
संपादित करें: हाँ ग्राहकों के दोनों जावा पर हैं और मैं SetSigningKeyFromKeyInfo विधि
मुझे लगता है कि आपको प्राप्त होने वाला दावा जावा जैसी गैर-नेटवर्क्स भाषा में उत्पन्न हुआ है? –
'SetSigningKeyFromKeyInfo (signXml) क्या करता है;' क्या करें? –
जब आपके पास आधार 64 डीकोडेड किया गया है, तो क्या आप एक्सएमएल को फ़ाइल में डंप कर सकते हैं और इसकी तुलना में अपने स्वयं के दावों में से एक (सूक्ष्म) संरचनात्मक असंगतताओं की जांच कर सकते हैं? –