Java client to WCF service interop with mutual certificate - Cannot resolve KeyInfo for verifying signature

对着背影说爱祢 提交于 2019-12-04 06:25:43

Actually I'm having the same problem, and i'm using the aproach suggested by Yaron Naveh.

I haven't finished yet, but I'm making some advances (I'll post a full answer when I finish).

The request uses an AsymmetricSecurityBindingElement, not a SymmetricSecurityBindingElement as Yaron suggested.

The Inclusion Mode of the X509SecurityTokenParameters should be set to SecurityTokenInclusionMode.AlwaysToInitiator

The binding should look like this

//Only the following MessageSecurityVersion are asimetric: 

//WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10
//WSSecurity10WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10

AsymmetricSecurityBindingElement abe =(AsymmetricSecurityBindingElement)
SecurityBindingElement.CreateMutualCertificateBindingElement(    
  MessageSecurityVersion.WSSecurity10WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10);

abe.SetKeyDerivation(false);

X509SecurityTokenParameters x509ProtectionParameters =
    new X509SecurityTokenParameters(X509KeyIdentifierClauseType.IssuerSerial);

x509ProtectionParameters.InclusionMode = SecurityTokenInclusionMode.AlwaysToInitiator;
x509ProtectionParameters.X509ReferenceStyle = X509KeyIdentifierClauseType.IssuerSerial;

abe.InitiatorTokenParameters = x509ProtectionParameters;
abe.SecurityHeaderLayout = SecurityHeaderLayout.Strict;
abe.DefaultAlgorithmSuite = SecurityAlgorithmSuite.TripleDesRsa15;

HttpTransportBindingElement httpBinding = new HttpTransportBindingElement();
System.ServiceModel.Channels.Binding binding = new CustomBinding(abe, httpBinding);
return binding;

I hope this helps a bit

please publish the whole request envelope here.

Generally in such cases I suggest to build a WCF client first and verify that it works. You could build a WCF client that sends a serial number like this:

SymmetricSecurityBindingElement messageSecurity = new SymmetricSecurityBindingElement();
X509SecurityTokenParameters x509ProtectionParameters = 
                new X509SecurityTokenParameters( X509KeyIdentifierClauseType.IssuerSerial);
messageSecurity.ProtectionTokenParameters = x509ProtectionParameters;
HttpTransportBindingElement httpBinding = new HttpTransportBindingElement();
Binding binding = new  CustomBinding(messageSecurity, httpBinding);

note the usage of X509KeyIdentifierClauseType.IssuerSerial. Possibly creating a server via a custom binding with this setting will solve the whole issue, but I suggest to start wcf to wcf.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!