Rodrigo
Wed Aug 24 20:48:21 CDT 2005
Thanks for your help, It was very usefull.
Greetings,
-Rodrigo
"Alex Feinman [MVP]" <public_news@alexfeinman.com> wrote in message
news:OzxUrxHqFHA.1024@TK2MSFTNGP09.phx.gbl...
> This KB artcile has C++ sample code.
>
http://support.microsoft.com/default.aspx?scid=kb;en-us;841060
>
> Basically it reads the content of the certificate file into a buffer and
> then uses CertOpenSystemStore(NULL, L"ROOT") and
> CertAddEncodedCertificateToStore(
> hRootStore,
> X509_ASN_ENCODING,
> pBuffer,
> dwFileSize,
> CERT_STORE_ADD_REPLACE_EXISTING,
> NULL));
>
> This should be trivial to P/Invoke
>
> [DllImport("Crypt32")]
> extern static uint CertAddEncodedCertificateToStore(
> IntPtr hCertStore,
> int dwCertEncodingType,
> byte[] pbCertEncoded,
> int cbCertEncoded,
> int dwAddDisposition,
> IntPtr ppCertContext
> );
>
> [DllImport("Crypt32")]
> extern static IntPtr CertOpenStore(
> int lpszStoreProvider,
> int dwEncodingType,
> IntPtr hCryptProv,
> int dwFlags,
> string pvPara
> );
>
> Call as
> hStore = CertOpenStore(10, 0, IntPtr.Zero, 0x10001, "ROOT" );
>
> Something like this. Sorry, I don't have time to test it right now
>
>
> const int CERT_STORE_ADD_REPLACE_EXISTING = 3;
> const int X509_ASN_ENCODING = 0x00000001;
>
> --
> Alex Feinman
> ---
> Visit
http://www.opennetcf.org
> "Rodrigo Meneses" <rmeneses@NOsmartmaticSPAMM.com> wrote in message
> news:usbYFOHqFHA.3108@TK2MSFTNGP12.phx.gbl...
>> Hi.
>> I need to install a ROOT X509 Certificate programmatically using C#.
>> Anyone know how can I achieve this? maybe P/Invoke over some core dll or
>> something?
>> Thanks in advance
>> -rodrigo meneses
>>
>>
>