Click here to Skip to main content
15,916,601 members
Home / Discussions / C#
   

C#

 
GeneralAdding HTML to the OE NewMessage Window Pin
ManjithMadhusudanan3-May-04 10:44
sussManjithMadhusudanan3-May-04 10:44 
GeneralCopy Portion of Bitmap Pin
Wackatronic3-May-04 9:50
Wackatronic3-May-04 9:50 
GeneralRe: Copy Portion of Bitmap Pin
Heath Stewart3-May-04 10:36
protectorHeath Stewart3-May-04 10:36 
GeneralRe: Copy Portion of Bitmap Pin
Colin Angus Mackay3-May-04 12:11
Colin Angus Mackay3-May-04 12:11 
Generalload crpe32.dll failed Pin
econnor3-May-04 9:40
econnor3-May-04 9:40 
GeneralRe: load crpe32.dll failed Pin
Heath Stewart3-May-04 10:35
protectorHeath Stewart3-May-04 10:35 
GeneralRe: load crpe32.dll failed Pin
leppie3-May-04 10:59
leppie3-May-04 10:59 
GeneralRe: How Do I Make a program to only execute once per session Pin
Dave Kreskowiak3-May-04 9:25
mveDave Kreskowiak3-May-04 9:25 
GeneralRe: How Do I Make a program to only execute once per session Pin
Dave Kreskowiak3-May-04 9:48
mveDave Kreskowiak3-May-04 9:48 
Generaldivil.co.uk's Document Manager. Pin
Marlun3-May-04 8:47
Marlun3-May-04 8:47 
GeneralRe: divil.co.uk's Document Manager. Pin
leppie3-May-04 11:15
leppie3-May-04 11:15 
GeneralRe: divil.co.uk's Document Manager. Pin
Marlun3-May-04 13:44
Marlun3-May-04 13:44 
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 

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.