I forgot : the private key is protected with a passphrase....
Tommy Grändefors - 23 Jun 2005 08:20 GMT
You must unprotect your private key before you can import it.
If you have generated your key through openssl, then you can transform
your private key to an unprotected DER encoded PKCS#8 key by executing:
openssl pkcs8 -nocrypt -topk8 -inform PEM -outform DER -in CA.key -out
CA.key.pkcs8
Then it can be successfully imported with your code (if you use the
PKCS8EncodedKeySpec).
Regards,
Tommy
www.pheox.com
> I forgot : the private key is protected with a passphrase....
Hi,
The X509EncodedKeySpec is used for generating public keys. Use the
PKCS8EncodedKeySpec instead and make sure that the private key in your
file is DER (binary) encoded according to the PKCS#8 format. If the key
is base64 encoded (ASCII) then you can convert it to binary by using
Sun's "unsupported" converter class sun.misc.BASE64Decoder.
Hope it solves your problem.
If not, you have to supply more informaetion regarding the format of
your private key file.
Regards,
Tommy
www.pheox.com
> Hi,
> I've 2 files : CA.cert (X509 certificate) and CA.key (contains private
[quoted text clipped - 49 lines]
> How to correct this?
> Thanks a lot.
Michel Gallant - 22 Jun 2005 22:31 GMT
Here is some sample code using PKCS8EncodedKeySpec:
http://www.jensign.com/JavaScience/PEM/RSAPVK8.java
Also, there are a number of the standard PrivateKeyInfo spec (as exported
by Java) to Microsoft/Windows PRIVATEKEYBLOB format converter
utilities here:
http://www.jensign.com/JavaScience/cryptoutils
- Mitch Gallant
JavaScience Consulting
www.jensign.com
Hi,
The X509EncodedKeySpec is used for generating public keys. Use the
PKCS8EncodedKeySpec instead and make sure that the private key in your
file is DER (binary) encoded according to the PKCS#8 format. If the key
is base64 encoded (ASCII) then you can convert it to binary by using
Sun's "unsupported" converter class sun.misc.BASE64Decoder.
Hope it solves your problem.
If not, you have to supply more informaetion regarding the format of
your private key file.
Regards,
Tommy
www.pheox.com
Benoît wrote:
> Hi,
> I've 2 files : CA.cert (X509 certificate) and CA.key (contains private
[quoted text clipped - 50 lines]
> How to correct this?
> Thanks a lot.
Benoît - 23 Jun 2005 09:21 GMT
Thanks for your informations...
I will certainly use them
Bye