在从Java发送到.NET的SOAP消息中,我们在标题后面的部分中包含:
<ds:KeyInfo Id="KI-[SOMETHING]">
<wsse:SecurityTokenReference wsu:Id="STR-[SOMETHING]">
<ds:X509Data>
<ds:X509IssuerSerial>
<ds:X509IssuerName>CN=MY,OU=SOMETHING,O=XXX</ds:X509IssuerName>
<ds:X509SerialNumber>1111111</ds:X509SerialNumber>
</ds:X509IssuerSerial>
</ds:X509Data>
</wsse:SecurityTokenReference>
</ds:KeyInfo>
我们得到的错误:
Cannot resolve KeyInfo for verifying signature: KeyInfo 'SecurityKeyIdentifier(
IsReadOnly = False,
Count = 1,
Clause[0] = X509IssuerSerialKeyIdentifierClause(Issuer = 'CN=MY,OU=SOMETHING,O=XXX', Serial = '1111111'))',
available tokens 'SecurityTokenResolver(TokenCount = 0,)
.NET WCF服务默认情况下不能使用此标头来验证消息。唯一可接受的方法是将完整证书包含在消息中(而不是存储路径),如下所示:
<ds:KeyInfo Id="KI-11035BFBDD92F5CE7C1399467228150959">
<ds:X509Data>
<ds:X509Certificate>[BASE 64 of certyficate]</ds:X509Certificate>
</ds:X509Data>
</ds:KeyInfo>
此处描述了类似问题及上述解决方案:http://blogs.msdn.com/b/dhrubach/archive/2010/06/18/10027513.aspx
但在我的情况下,我无法改变Java中的服务。我看到以下解决方案:
所以我的问题是,我可以在WSSecurity验证之前以某种方式拦截消息,还是有其他方法可以在.NET中实现此类消息的验证?