Groups | Blog | Home
all groups > dotnet web services enhancements > october 2005 >

dotnet web services enhancements : Specify client certificate in code WSE 3.0


Lieven
10/25/2005 2:10:03 PM
Hey,

I'm new to wse. I installed WSE 3.0. In the wizard we can choose to specifiy
the client certificate in code. Can someone explain me how this can be done??

Thanks!

grt,

Lieven
10/26/2005 12:04:02 AM
Hey,

Thanks for the code. I will try this code this evening and will let you know
if this works.

Thanks!!

grt,

Lieven

[quoted text, click to view]
Jon
10/26/2005 8:31:54 AM
Here is some code to use both a server and client certificate. Hope it
helps. Works with WSE 3.0 Oct CTP

Replace MyCertificate with your client certificate and ServerCertificate
with the servers

MutualCertificate11Assertion assertion = new
MutualCertificate11Assertion();
X509TokenProvider clientToken = new X509TokenProvider();
clientToken.StoreLocation = StoreLocation.LocalMachine;
clientToken.StoreName = StoreName.My;
clientToken.FindType =
X509FindType.FindBySubjectDistinguishedName;
clientToken.FindValue = "CN=MyCertificate";

object o = clientToken.GetToken();

assertion.ClientX509TokenProvider = clientToken;
assertion.ServiceX509TokenProvider = new
X509TokenProvider(StoreLocation.LocalMachine, StoreName.My,
"CN=ServerCertificate", X509FindType.FindBySubjectDistinguishedName);

o = assertion.ServiceX509TokenProvider.GetToken();

assertion.Protection.Request.SignatureOptions =
SignatureOptions.IncludeAddressing | SignatureOptions.IncludeTimestamp |
SignatureOptions.IncludeSoapBody;
assertion.Protection.Request.EncryptBody = true;
assertion.Protection.Response.SignatureOptions =
SignatureOptions.IncludeAddressing | SignatureOptions.IncludeTimestamp |
SignatureOptions.IncludeSoapBody;
assertion.Protection.Response.EncryptBody = true;
assertion.Protection.Fault.SignatureOptions =
SignatureOptions.IncludeAddressing | SignatureOptions.IncludeTimestamp |
SignatureOptions.IncludeSoapBody;
assertion.Protection.Fault.EncryptBody = false;

assertion.RequireSignatureConfirmation= true;
assertion.RequireDerivedKeys = true;
assertion.MessageProtectionOrder =
MessageProtectionOrder.SignBeforeEncrypt;
assertion.EstablishSecurityContext = true;
assertion.RenewExpiredSecurityContext = true;
assertion.ClientActor = "";

Policy p = Policy(new PolicyAssertion[] { assertion });



[quoted text, click to view]

AddThis Social Bookmark Button