Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Convert Cert Request from PEM to DER and SHA1 hash.

843811May 16 2005 — edited May 25 2005
Hi,

I have a certificate request in PEM format as a block of ascii text

e.g. (Note the request below is invalid)
-----BEGIN CERTIFICATE REQUEST-----
MIIBzzCCATgCAQAwgYExGjAYBgNVBAoTEUJhcmNsYXlzIEJhbmsgUExDMSIwIAYDVQQLExlQVVJO
IDk5ODg3NzY2NTUxMTU1NDQzMzIyMQ8wDQYDVQQLEwZDTlVNIDExGTAXBgNVBAsTEENPUkcgV2lk
Z2V0cyBQTEMxEzARBgNVBAMTCldpZGdldEhTTTEwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGB
cs9ZixtOaphaKPqNayOTAgMBAAGgDTALBgNVHQ8xBAMCBsAwDQYJKoZIhvcNAQEFBQADgYEAe+uo
neMUt8z05BGGytJcGeM1xbCqnyVansMgaTZi+uoAH3rwNo/ulhfe+7mTqMA5Omoj/BSsXm4Y3DNV
XL5h9V50vdMaz+M=
-----END CERTIFICATE REQUEST-----
which I can manipulate in openssl, e.g.

OpenSSL> req -inform pem -in request999.txt -out test999.der -outform der

OpenSSL> dgst -sha1 test999.der
SHA1(test999.der)= c4f7cefb62bcfd3edc74af0f6596055b64d1dbb2
OpenSSL>

However I need to use java to do the same/following without going through openssl command line tool:

1) DER encode
2) SHA-1 hash it
3) Extract public key

I have been unable to get this to work in bouncy castle (due to limited java skills).Is there anyone out there who has an example of this working.

Any help appreciated.
Kevin
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 22 2005
Added on May 16 2005
1 comment
1,688 views