IIS Server Security - SSLCertHash through ADSI in C#

This is Interesting: Free IT Magazines  
Home > Archive > IIS Server Security > June 2006 > SSLCertHash through ADSI in C#





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author SSLCertHash through ADSI in C#
Raghu

2006-06-29, 3:37 pm

Typed last line wrong and it is:

site.Properties["SSLCertHash"].Value = thumbPrintBytes;

It still errors...


"Raghu" <RaghuNoSpam> wrote in message
news:e%237xBt7mGHA.3376@TK2MSFTNGP03.phx.gbl...
>I am trying to set the SSLCertHash property to the byte array that contains
>the SSL certificate's thumbnail with following code:
>
> string path = "IIS://localhost/W3SVC/" + webSiteNumber;
> DirectoryEntry site = new DirectoryEntry(path);
>
> X509Certificate2 sslCertificate =
> Utility. GetSSLCertificate(distinguishedSubjectNa
me, true);
>
> string thumbPrintInHex = sslCertificate.Thumbprint;
> byte[] thumbPrintBytes =
> Utility.ToByteArray(thumbPrintInHex);
>
> site.Properties["SSLStoreName"].Value = "MY";
> site.Properties["SSLCertHash"].Value = new
> byte[thumbPrintBytes.Length];
>
> The last line (that sets the SSLCertHash property value) throws
> {"Exception from HRESULT: 0x8000500C"}. Any help is appreciated.
>
> Thanks.
> Raghu/..
>
>
>



Raghu

2006-06-29, 7:21 pm

I am trying to set the SSLCertHash property to the byte array that contains
the SSL certificate's thumbnail with following code:

string path = "IIS://localhost/W3SVC/" + webSiteNumber;
DirectoryEntry site = new DirectoryEntry(path);

X509Certificate2 sslCertificate =
Utility. GetSSLCertificate(distinguishedSubjectNa
me, true);

string thumbPrintInHex = sslCertificate.Thumbprint;
byte[] thumbPrintBytes =
Utility.ToByteArray(thumbPrintInHex);

site.Properties["SSLStoreName"].Value = "MY";
site.Properties["SSLCertHash"].Value = new
byte[thumbPrintBytes.Length];

The last line (that sets the SSLCertHash property value) throws {"Exception
from HRESULT: 0x8000500C"}. Any help is appreciated.

Thanks.
Raghu/..



Raghu

2006-06-29, 7:21 pm

Typed last line wrong and it is:

site.Properties["SSLCertHash"].Value = thumbPrintBytes;

It still errors...


"Raghu" <RaghuNoSpam> wrote in message
news:e%237xBt7mGHA.3376@TK2MSFTNGP03.phx.gbl...
>I am trying to set the SSLCertHash property to the byte array that contains
>the SSL certificate's thumbnail with following code:
>
> string path = "IIS://localhost/W3SVC/" + webSiteNumber;
> DirectoryEntry site = new DirectoryEntry(path);
>
> X509Certificate2 sslCertificate =
> Utility. GetSSLCertificate(distinguishedSubjectNa
me, true);
>
> string thumbPrintInHex = sslCertificate.Thumbprint;
> byte[] thumbPrintBytes =
> Utility.ToByteArray(thumbPrintInHex);
>
> site.Properties["SSLStoreName"].Value = "MY";
> site.Properties["SSLCertHash"].Value = new
> byte[thumbPrintBytes.Length];
>
> The last line (that sets the SSLCertHash property value) throws
> {"Exception from HRESULT: 0x8000500C"}. Any help is appreciated.
>
> Thanks.
> Raghu/..
>
>
>



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com