Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

X509ContentType

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 09-07-2007   #1 (permalink)
Joe G
Guest


 

X509ContentType

I've been using a powershell script to export certificates from the
computer's personal store.

There appears to be 8 members of the subject enumeration

217# [System.Security.Cryptography.X509Certificates.X509ContentType]::Pfx = ""
Exception setting "Pfx": "Cannot convert value "" to type "System.Security.Cry
tography.X509Certificates.X509ContentType" due to invalid enumeration values.
pecify one of the following enumeration values and try again. The possible enu
eration values are "Unknown, Cert, SerializedCert, Pfx, Pkcs12,
SerializedStore
, Pkcs7, Authenticode"."
At line:1 char:66
+ [System.Security.Cryptography.X509Certificates.X509ContentType]::P <<<< fx =

I don't have any issues when I use the content types Cert, SerializedCert,
Pfx, Pkcs12

All the others (Unknown, SerializedStor, Pkcs7, Authenticode) yield the
likes of

Exception calling "Export" with "2" argument(s): "Invalid content type."
At C:\IMCSBU\Enrollment\test1.ps1:94 char:28
+ $certbytes = $cert.Export( <<<<
[System.Security.Cryptography.X509Certifica
tes.X509ContentType]::Pkcs7, $strPassword)

I was questioning if this is limitation of back-end classes used by the
powershell infrastructure or interface with same?



My System SpecsSystem Spec
Old 09-07-2007   #2 (permalink)
Oisin Grehan
Guest


 

Re: X509ContentType

On Sep 7, 12:40 pm, Joe G <J...@xxxxxx> wrote:
Quote:

> I've been using a powershell script to export certificates from the
> computer's personal store.
>
> There appears to be 8 members of the subject enumeration
>
> 217# [System.Security.Cryptography.X509Certificates.X509ContentType]::Pfx = ""
> Exception setting "Pfx": "Cannot convert value "" to type "System.Security.Cry
> tography.X509Certificates.X509ContentType" due to invalid enumeration values.
> pecify one of the following enumeration values and try again. The possible enu
> eration values are "Unknown, Cert, SerializedCert, Pfx, Pkcs12,
> SerializedStore
> , Pkcs7, Authenticode"."
> At line:1 char:66
> + [System.Security.Cryptography.X509Certificates.X509ContentType]::P <<<< fx =
>
> I don't have any issues when I use the content types Cert, SerializedCert,
> Pfx, Pkcs12
>
> All the others (Unknown, SerializedStor, Pkcs7, Authenticode) yield the
> likes of
>
> Exception calling "Export" with "2" argument(s): "Invalid content type."
> At C:\IMCSBU\Enrollment\test1.ps1:94 char:28
> + $certbytes = $cert.Export( <<<<
> [System.Security.Cryptography.X509Certifica
> tes.X509ContentType]::Pkcs7, $strPassword)
>
> I was questioning if this is limitation of back-end classes used by the
> powershell infrastructure or interface with same?
This is expected. The only valid content types for certificate export
are Cert, SerializedCert, and Pkcs12. This enumeration is used in
various places in the crypto APIs; it's not solely for use in export.

Hope this helps,

- Oisin

My System SpecsSystem Spec
Old 09-07-2007   #3 (permalink)
Joe G
Guest


 

Re: X509ContentType

Thank you Oisin, especially for reminding me that the subject enumeration is
used other places. By the way is was able to the pfx to work (but it's the
same as the pkcs12). At first I was thinking that one of them would mimic
the DER Base64 export scenario but it was wishfull thinking. I guess I'll
just have to take the bytes output by the export process, convert them to a
base64 string and output them my selves.

"Oisin Grehan" wrote:
Quote:

> On Sep 7, 12:40 pm, Joe G <J...@xxxxxx> wrote:
Quote:

> > I've been using a powershell script to export certificates from the
> > computer's personal store.
> >
> > There appears to be 8 members of the subject enumeration
> >
> > 217# [System.Security.Cryptography.X509Certificates.X509ContentType]::Pfx = ""
> > Exception setting "Pfx": "Cannot convert value "" to type "System.Security.Cry
> > tography.X509Certificates.X509ContentType" due to invalid enumeration values.
> > pecify one of the following enumeration values and try again. The possible enu
> > eration values are "Unknown, Cert, SerializedCert, Pfx, Pkcs12,
> > SerializedStore
> > , Pkcs7, Authenticode"."
> > At line:1 char:66
> > + [System.Security.Cryptography.X509Certificates.X509ContentType]::P <<<< fx =
> >
> > I don't have any issues when I use the content types Cert, SerializedCert,
> > Pfx, Pkcs12
> >
> > All the others (Unknown, SerializedStor, Pkcs7, Authenticode) yield the
> > likes of
> >
> > Exception calling "Export" with "2" argument(s): "Invalid content type."
> > At C:\IMCSBU\Enrollment\test1.ps1:94 char:28
> > + $certbytes = $cert.Export( <<<<
> > [System.Security.Cryptography.X509Certifica
> > tes.X509ContentType]::Pkcs7, $strPassword)
> >
> > I was questioning if this is limitation of back-end classes used by the
> > powershell infrastructure or interface with same?
>
> This is expected. The only valid content types for certificate export
> are Cert, SerializedCert, and Pkcs12. This enumeration is used in
> various places in the crypto APIs; it's not solely for use in export.
>
> Hope this helps,
>
> - Oisin
>
>
My System SpecsSystem Spec
Old 09-07-2007   #4 (permalink)
Oisin Grehan
Guest


 

Re: X509ContentType

On Sep 7, 12:40 pm, Joe G <J...@xxxxxx> wrote:
Quote:

> I've been using a powershell script to export certificates from the
> computer's personal store.
>
> There appears to be 8 members of the subject enumeration
>
> 217# [System.Security.Cryptography.X509Certificates.X509ContentType]::Pfx = ""
> Exception setting "Pfx": "Cannot convert value "" to type "System.Security.Cry
> tography.X509Certificates.X509ContentType" due to invalid enumeration values.
> pecify one of the following enumeration values and try again. The possible enu
> eration values are "Unknown, Cert, SerializedCert, Pfx, Pkcs12,
> SerializedStore
> , Pkcs7, Authenticode"."
> At line:1 char:66
> + [System.Security.Cryptography.X509Certificates.X509ContentType]::P <<<< fx =
>
> I don't have any issues when I use the content types Cert, SerializedCert,
> Pfx, Pkcs12
>
> All the others (Unknown, SerializedStor, Pkcs7, Authenticode) yield the
> likes of
>
> Exception calling "Export" with "2" argument(s): "Invalid content type."
> At C:\IMCSBU\Enrollment\test1.ps1:94 char:28
> + $certbytes = $cert.Export( <<<<
> [System.Security.Cryptography.X509Certifica
> tes.X509ContentType]::Pkcs7, $strPassword)
>
> I was questioning if this is limitation of back-end classes used by the
> powershell infrastructure or interface with same?
Btw, the Pfx enumeration is just an alias for Pkcs12.

- Oisin

My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes




Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51