Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / October 2005

Tip: Looking for answers? Try searching our database.

Specify client certificate in code WSE 3.0

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lieven - 25 Oct 2005 22:10 GMT
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
Jon - 25 Oct 2005 23:31 GMT
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 });

> Hey,
>
[quoted text clipped - 8 lines]
>
> Lieven
Lieven - 26 Oct 2005 08:04 GMT
Hey,

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

Thanks!!

grt,

Lieven

> Here is some code to use both a server and client certificate. Hope it
> helps. Works with WSE 3.0 Oct CTP
[quoted text clipped - 55 lines]
> >
> > Lieven

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.