Discussion:
Windows and p12 files
Gregory Sloop
2014-10-23 16:48:12 UTC
Permalink
Ok, so I know this isn't strictly an OpenSSL question, so I apologize - but I'd guess someone here knows the answer, or can direct me to the correct resource. [I've done a lot of searches, but no real luck.]

I'm trying to import both a private key and certificate generated with OpenSSL into a Windows client. [Lets assume Win7 and 8]
It looks like p12 files are probably the best way to go. [Glad to stand corrected, but that's what it looks like to me.]

So, I've cranked out a p12 file [converted from seperate PEM files, also initially generated with OpenSSL] with the client-private-key and client-cert inside.
(Like so: openssl pkcs12 -keypbe aes-256-cbc -export -inkey infile.key -in infile.crt -out outfile.p12)

I initially tried encrypting it with "-keypbe aes-256-cbc" - however Windows barfs on it. [This should encrypt the p12 with AES-256, I think.]


I did it again, using "-descert" [which, AFAICT should encrypt with 3DES]
(Like so: openssl pkcs12 -descert -export -inkey infile.key -in infile.crt -out outfile.p12)

Windows likes this second one.

While 3DES is probably "good enough" - I'd rather use AES-256.

So the root of my question is:
1) What formats can Windows [7/8] accept? [Pointers somewhere would be good - google didn't help me find much.]
2) Is there some reasonable way to generate/convert the key/cert using OpenSSL, to use something better than 3DES that Windows will accept?

TIA for any light you can shed on the situation.

[I have similar questions about OSX - so if you have data about OSX that would be handy too. However, OSX isn't as critical to me at the moment, so I'm not as exercised about it. :) ]

-Greg
Dr. Stephen Henson
2014-10-23 22:07:17 UTC
Permalink
Post by Gregory Sloop
Ok, so I know this isn't strictly an OpenSSL question, so I apologize - but I'd guess someone here knows the answer, or can direct me to the correct resource. [I've done a lot of searches, but no real luck.]
I'm trying to import both a private key and certificate generated with OpenSSL into a Windows client. [Lets assume Win7 and 8]
It looks like p12 files are probably the best way to go. [Glad to stand corrected, but that's what it looks like to me.]
So, I've cranked out a p12 file [converted from seperate PEM files, also initially generated with OpenSSL] with the client-private-key and client-cert inside.
(Like so: openssl pkcs12 -keypbe aes-256-cbc -export -inkey infile.key -in infile.crt -out outfile.p12)
I initially tried encrypting it with "-keypbe aes-256-cbc" - however Windows barfs on it. [This should encrypt the p12 with AES-256, I think.]
I did it again, using "-descert" [which, AFAICT should encrypt with 3DES]
(Like so: openssl pkcs12 -descert -export -inkey infile.key -in infile.crt -out outfile.p12)
Windows likes this second one.
While 3DES is probably "good enough" - I'd rather use AES-256.
1) What formats can Windows [7/8] accept? [Pointers somewhere would be good - google didn't help me find much.]
2) Is there some reasonable way to generate/convert the key/cert using OpenSSL, to use something better than 3DES that Windows will accept?
Well PKCS#12 is rather an old standard. It includes its own key derivation
algorithm and OIDs. Specifically:

pbeWithSHAAnd128BitRC4
pbeWithSHAAnd40BitRC4
pbeWithSHAAnd3-KeyTripleDES-CBC
pbeWithSHAAnd2-KeyTripleDES-CBC
pbeWithSHAAnd128BitRC2-CBC
pbewithSHAAnd40BitRC2-CBC

When you use -descert you end up using pbeWithSHAAnd3-KeyTripleDES-CBC for
certificates and that same algorithm is used by default for private keys.

For AES a different key derivation algorithm can be used which is part of
PKCS#5 v2.0.

Some implementations may only use the algorithms in the PKCS#12 standard
itself which would explain the problems you were having.

Steve.
--
Dr Stephen N. Henson. OpenSSL project core developer.
Commercial tech support now available see: http://www.openssl.org
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users-MCmKBN63+***@public.gmane.org
Automated List Manager majordomo-MCmKBN63+***@public.gmane.org
Viktor Dukhovni
2014-10-23 23:21:36 UTC
Permalink
Post by Gregory Sloop
TIA for any light you can shed on the situation.
For Windows 7/2008 compatible PKCS#12 files I use:

#! /bin/bash
...
openssl pkcs12 -export -name "$1" \
-inkey "$1-key.pem" -in "$1-cert.pem" -chain -CAfile rootcert.pem \
-keyex -CSP "Microsoft Strong Cryptographic Provider" \
-passin file:<(builtin printf "%s\n" "$pass") \
-passout file:<(builtin printf "%s\n" "$pfxpass") \
-certpbe PBE-SHA1-3DES -keypbe PBE-SHA1-3DES -out "$1".pfx

which indeed uses 3DES keys for the certificate and key. I guess
AES did not work for me either. I have not tested Windows 8/2012.
--
Viktor.
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users-MCmKBN63+***@public.gmane.org
Automated List Manager majordomo-MCmKBN63+***@public.gmane.org
Loading...