SSLCertHash through ADSI in C#
am 29.06.2006 22:33:17 von Raghu
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(distinguishedSubjectName, 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/..
Re: SSLCertHash through ADSI in C#
am 29.06.2006 22:37:39 von Raghu
Typed last line wrong and it is:
site.Properties["SSLCertHash"].Value = thumbPrintBytes;
It still errors...
"Raghu" 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(distinguishedSubjectName, 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/..
>
>
>
Re: SSLCertHash through ADSI in C#
am 29.06.2006 22:37:39 von Raghu
Typed last line wrong and it is:
site.Properties["SSLCertHash"].Value = thumbPrintBytes;
It still errors...
"Raghu" 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(distinguishedSubjectName, 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/..
>
>
>