Derwynd's Weblog

Derwynd's Weblog

Extracting certificates from java keystore to use in apache.conf

So you have a javakeystore and want to extract the certificate….

heres what I did .. of course I had the passphrase

Downloaded ….
$ java-1.6.0-openjdk-1.6.0.0-0.25.b09.el5.x86_64.rpm

$ rpm -ivh java-1.6.0-openjdk-1.6.0.0-0.25.b09.el5.x86_64.rpm

$ cd /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/bin/keytool

and
$ ./keytool -importkeystore -srckeystore /opt/certs/final/NetworthKeyStore -destkeystore /tmp/mystore.p12 -srcstoretype JKS -deststoretype PKCS12 -noprompt

Enter destination keystore password:
Re-enter new password:
Enter source keystore password:
Entry for alias networthpnbkey successfully imported.
Import command completed: 1 entries successfully imported, 0 entries failed or cancelled

where KeyStore is the java keystore name

So I got a /tmp/mystore.p12 with everything great
now for some ssl magic
$ openssl pkcs12 -info -in /tmp/mystore.p12

Enter Import Password:
MAC Iteration 1024
MAC verified OK
PKCS7 Data
Shrouded Keybag: pbeWithSHA1And3-KeyTripleDES-CBC, Iteration 1024
Bag Attributes
friendlyName: pubkey
localKeyID: 52 69 3D 69 50 41 22 69 33 34 36 36 32 34 34 36 30 35
Key Attributes:
Enter PEM pass phrase:
Verifying – Enter PEM pass phrase:

Copy the following from output…….

—–BEGIN RSA PRIVATE KEY—–
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,FE731BD9D499A31B

d12tLvqVX0a3FxOba+uwCiJIxEC8dESEI9GI5Doz1hieu8pZKoz3bwozDBLfLlFA
lvPj4Qi2FmazrZWRTNHQOUcv4aVQ1TmauRtw/LMoieR0b4+VkqTzk/eAe6d3pfr/
BoZxs40f0YaYsgMyYj0HWOIFXmCZnfEgzQBVZPIqcUzBxrV4g7xwjbLBXHJ+wAv+
p+3/ejYvxz/lfn+Nd00TlUZu770wPlRzQT4hwjWuNVfmadA+FpBMk4uW8dDSEMMc
KyW2Qg2nLfXlxMxLIb7DB86eJUS5W5bAHi1S5RNiSNR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cbHEmaWXCzIVgUWPYJAgMBAAGg
ADANBgkqhkiG9w0BAQUFAAOBgQB2rRr2bc+3iQEGvc5zSr9/nw1YBCGJBfMThe+V
KoZIhvcNAQkBFhJpZGNAcGxhbmV0bGFyZy5uZXQwgZ8wDQYJKoZIhvcNAQEBBQAD
A1UECxMLSURDIHN1cHBvcnQxFzAVBgNVBAMTDnd3dy5kb21haW4uY29tMSEwHwYJ
ADANBgkqhkiG9w0BAQUFAAOBgQB2rRr2bc+3iQEGvc5zSr9/nw1YBCGJBfMThe+V
bmRzMREwDwYDVQQHEwhDb3ZlbnRyeTETMBEGAAUEChMKUGxhbmV0bGFyZzEUMBIG
WdIpJN6cONDEF8hXtEKbpSmeu7ioUsLWDiQJ/Vab/XR9Uz9gsjs7ztm6ZTFhlYUD
HBiePsg26oDwlQ5XOvi+jslQN+u6CQo2rlzMn4OoKrBufp3g2IgRrrwRSxOLpJeX
KaAO32si+7euiprm79a3CcRrWSjpfKX6FhkGIu9BbQ==
—–END CERTIFICATE—–

Go ahead and import in your apache config

Advertisements

January 14, 2010 - Posted by | Uncategorized

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: