Home All Groups Group Topic Archive Search About

load CAPICOM Certificate from X509Certificate

Author
7 Aug 2006 5:08 PM
Joao Maia
Hi there,

Does anyone know of a way to instantiate a CAPICOM Certificate object
from a .NET X509Certificate certificate object ? There is some
functionality I need for for a certificate (export to PFX) that I can't
do in the .NET X509Certificate object, so I'll need to use CAPICOM for
that.

I have already got code written in .NET for the user to go and select a
certificate from his certificate store. That code returns a
X509Certificate object (the one the user selected). I want to avoid
having to rewrite that code again in CAPICOM, so I thought that maybe
there's a way to instantiate a CAPICOM certificate from a
X509Certificate

I tried to do a GetRawCertData to get a string and then importing it to
the CAPICOM Certificate object with the Import method and apparently it
works, but the PrivateKey attribute of the created CAPICOM Certificate
object throws an Exception (COM Exception, I think).

Any ideas on this ? Or should I start rewriting code for the user
certificate selection using CAPICOM instead of .net managed code ?

Cheers,

jm

Author
5 Dec 2006 5:36 PM
claudio
Hi Joao,
unfortunately I can't help you. I'm still trying to implement certificate
selection from the store. Where did you find the code for doing this?
THanks,
Kind regards,
Claudio

Show quoteHide quote
"Joao Maia" wrote:

> Hi there,
>
> Does anyone know of a way to instantiate a CAPICOM Certificate object
> from a .NET X509Certificate certificate object ? There is some
> functionality I need for for a certificate (export to PFX) that I can't
> do in the .NET X509Certificate object, so I'll need to use CAPICOM for
> that.
>
> I have already got code written in .NET for the user to go and select a
> certificate from his certificate store. That code returns a
> X509Certificate object (the one the user selected). I want to avoid
> having to rewrite that code again in CAPICOM, so I thought that maybe
> there's a way to instantiate a CAPICOM certificate from a
> X509Certificate
>
> I tried to do a GetRawCertData to get a string and then importing it to
> the CAPICOM Certificate object with the Import method and apparently it
> works, but the PrivateKey attribute of the created CAPICOM Certificate
> object throws an Exception (COM Exception, I think).
>
> Any ideas on this ? Or should I start rewriting code for the user
> certificate selection using CAPICOM instead of .net managed code ?
>
> Cheers,
>
> jm
>
>
Author
13 Dec 2006 8:20 AM
sandeepkg
Try creating a certificate using Certificate.Import method. You should
use the string returned by below call as parameter for the Import
function:

Convert.ToBase64String(X509Certificate2.GetRawCertData())

Regards,
Sandeep