Click here to Skip to main content
15,887,175 members
Home / Discussions / C#
   

C#

 
Generalsp_helpfile Execute Pin
betterc3-May-04 8:45
betterc3-May-04 8:45 
GeneralRe: sp_helpfile Execute Pin
leppie3-May-04 8:57
leppie3-May-04 8:57 
GeneralRe: sp_helpfile Execute Pin
betterc3-May-04 9:30
betterc3-May-04 9:30 
GeneralRe: sp_helpfile Execute Pin
Heath Stewart3-May-04 10:10
protectorHeath Stewart3-May-04 10:10 
GeneralRe: sp_helpfile Execute Pin
betterc3-May-04 10:50
betterc3-May-04 10:50 
GeneralRe: sp_helpfile Execute Pin
Heath Stewart4-May-04 2:44
protectorHeath Stewart4-May-04 2:44 
GeneralSOAP over SSL with Certificate Pin
christer_evenius@hotmail.com3-May-04 7:14
christer_evenius@hotmail.com3-May-04 7:14 
GeneralRe: SOAP over SSL with Certificate Pin
Henrik Stuart3-May-04 7:34
Henrik Stuart3-May-04 7:34 
This... is a long road with many a winding turn... took me quite some time to get everything working correctly.

You fail to specify whether your C#-app is an ASP.NET web service client or a console/winforms web service client. I'll presume it's the latter as that's remarkably easier.

At either length it's easiest to use Microsoft WSE 1.0 enhancements[^] to fetch the certificate from the certificate store.

By default it is presumed that your client certificate is in the personal store of the current user (e.g. the one that is executing the application). If this is ASP.NET then as the user doesn't have a login profile the user doesn't have a personal store folder either and you need to carefully import the certificate to the personal store of the local machine.

The following code will get the private certificate from the depths of the certificate store:

<br />
byte[] certhash = { 50, 49, 239, 183, 249, 60, 36, 134, 129, 159, 39, <br />
                          226, 197, 70, 76, 1, 147, 237, 43, 217 };<br />
<br />
X509CertificateStore store = X509CertificateStore.CurrentUserStore(X509CertificateStore.MyStore);<br />
store.Open();<br />
X509CertificateCollection certs = store.FindCertificateByHash(certhash);<br />
store.Close();<br />
X509Certificate cert = certs[0];<br />


There are other ways to find a certificate than by using its hash value, but you can refer to the WSE 1.0 documentation for these.

Now, to add the certificate to the service call let's presume your web service object is Service1 then you add it fairly simply using:

<br />
Service1.ClientCertificates.Add(cert);<br />


It doesn't seem so daunting when you look at it like this, but it can take a lot of time to figure out given the.... usefulness.... of most code examples around. I think that's all it takes, good luck fighting the certificate mmc snap-in. Smile | :)

Hope this helps.

--
Henrik Stuart (http://www.unprompted.com/hstuart/[^])
GeneralRe: Newbie Webservice Problem Pin
mjmcinto3-May-04 6:45
mjmcinto3-May-04 6:45 
GeneralRe: Newbie Webservice Problem Pin
Heath Stewart3-May-04 10:29
protectorHeath Stewart3-May-04 10:29 
GeneralNewbie -- How to use multiple forms not MDI Pin
Daniel Stagg3-May-04 6:24
Daniel Stagg3-May-04 6:24 
GeneralRe: Newbie -- How to use multiple forms not MDI Pin
Dave Kreskowiak3-May-04 7:16
mveDave Kreskowiak3-May-04 7:16 
GeneralRe: Newbie -- How to use multiple forms not MDI Pin
Daniel Stagg3-May-04 7:19
Daniel Stagg3-May-04 7:19 
GeneralRe: Newbie -- How to use multiple forms not MDI Pin
Dave Kreskowiak3-May-04 9:19
mveDave Kreskowiak3-May-04 9:19 
GeneralProblem in MessageQueue Pin
rbarzallo3-May-04 6:21
rbarzallo3-May-04 6:21 
GeneralRe: Problem in MessageQueue Pin
Jeff Varszegi3-May-04 10:21
professionalJeff Varszegi3-May-04 10:21 
GeneralRe: Problem in MessageQueue Pin
Heath Stewart3-May-04 10:26
protectorHeath Stewart3-May-04 10:26 
GeneralRe: Problem in MessageQueue Pin
Jeff Varszegi3-May-04 11:07
professionalJeff Varszegi3-May-04 11:07 
GeneralRe: Problem in MessageQueue Pin
rbarzallo4-May-04 12:35
rbarzallo4-May-04 12:35 
GeneralRe: Problem in MessageQueue Pin
Jeff Varszegi4-May-04 12:42
professionalJeff Varszegi4-May-04 12:42 
QuestionHelp: Outlook Add-In. How do I set the button icon? Pin
Tony Archer3-May-04 6:15
Tony Archer3-May-04 6:15 
AnswerRe: Help: Outlook Add-In. How do I set the button icon? Pin
Heath Stewart3-May-04 10:24
protectorHeath Stewart3-May-04 10:24 
GeneralRe: Help: Outlook Add-In. How do I set the button icon? Pin
Tony Archer3-May-04 11:10
Tony Archer3-May-04 11:10 
GeneralRe: Help: Outlook Add-In. How do I set the button icon? Pin
Heath Stewart4-May-04 2:48
protectorHeath Stewart4-May-04 2:48 
GeneralXmlDocument to TextBox (Best Practise) Pin
Michael P Butler3-May-04 5:51
Michael P Butler3-May-04 5:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.