1
所以我在這裏有一個非常類似的問題。 SOAP KeyInfo values在SOAP請求中添加KeyInfo參考
我想在KeyInfo中添加引用,但似乎無法找到通過代碼執行的方法。
這裏是預期的輸出應該是什麼:
<KeyInfo>
<wsse:SecurityTokenReference>
<wsse:Reference URI="#SecurityTest" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/>
</wsse:SecurityTokenReference>
</KeyInfo>
而且我確實有這個上面它嘗試引用自:
<wsse:BinarySecurityToken ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"
EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
wsu:Id="SecurityTest">Base64CertStuffBlahblah
</wsse:BinarySecurityToken>
在創建的密鑰信息部分將盡力只允許我插入一個項目,像一個鍵,填寫這部分,但我只是想參考。這段代碼是我一直在努力的,但目前還沒有創造出我想要的。
//This creates a X509 clause but it's as far as I've got.
//The "keyInfoData" needs to be of a different type to allow custom reference?
var signer = new SignedXmlWithId(doc) {SigningKey = Key};
KeyInfo keyInfo = new KeyInfo();
KeyInfoX509Data keyInfoData = new KeyInfoX509Data();
keyInfoData.AddCertificate(cert);
keyInfo.AddClause(keyInfoData);
signer.KeyInfo = keyInfo;
感謝您的期待,任何幫助將不勝感激。