Results 1 to 1 of 1
  1. #1
    dkmishra001 is offline Member
    Join Date
    Mar 2012
    Rep Power

    Default how to calculate the public key of an x509 certificate in java

    In our project we have requirement to get the "public key of an x509 certificate" and "sha1 of public key of x509 certificate".
    I am using X509Certificate.getPublicKey() to get byte array and them I calculate the hexadecimal form of the byte array.

    Following is a sample value I get:

    30820122300d06092a864886f70d01010105000382010f0030 82010a0282010100af240808297a359e600caae74b3b4edc7c bc3c451cbb2be0fe2902f95708a364851527f5f1adc831895d 22e82aaaa642b38ff8b955b7b1b74bb3fe8f7e0757ecef43db 66621561cf600da4d8def8e0c362083d5413eb49ca59548526 e52b8f1b9febf5a191c23349d843636a524bd28fe870514dd1 89697bc770f6b3dc1274db7b5d4b56d396bf1577a1b0f4a225 f2af1c926718e5f40604ef90b9e400e4dd3ab519ff02baf43c eee08beb378becf4d7acf2f6f03dafdd759133191d1c40cb74 24192193d914feac2a52c78fd50449e48d6347883c6983cbfe 47bd2b7e4fc595ae0e9dd4d143c06773e314087ee53f9f73b8 330acf5d3f3487968aee53e825150203010001

    Public key of a certificate can be seen on windows by double clicking it and seeing the value of "public key" in details tab.
    the value is following for the same above certificate:

    3082010a0282010100af240808297a359e600caae74b3b4edc 7cbc3c451cbb2be0fe2902f95708a364851527f5f1adc83189 5d22e82aaaa642b38ff8b955b7b1b74bb3fe8f7e0757ecef43 db66621561cf600da4d8def8e0c362083d5413eb49ca595485 26e52b8f1b9febf5a191c23349d843636a524bd28fe870514d d189697bc770f6b3dc1274db7b5d4b56d396bf1577a1b0f4a2 25f2af1c926718e5f40604ef90b9e400e4dd3ab519ff02baf4 3ceee08beb378becf4d7acf2f6f03dafdd759133191d1c40cb 7424192193d914feac2a52c78fd50449e48d6347883c6983cb fe47bd2b7e4fc595ae0e9dd4d143c06773e314087ee53f9f73 b8330acf5d3f3487968aee53e825150203010001

    We see that the public key value calculated java has 44 extra characters in the begening, and then the value from 45th character is same as the public key calculated by windows.
    Please help us in knowing how to calculate public key in java so that its value is same as calculated by windows.

    Thank You,
    Last edited by dkmishra001; 03-19-2012 at 12:04 PM.

Similar Threads

  1. Help with JDBC and x509
    By porchrat in forum JDBC
    Replies: 7
    Last Post: 07-16-2012, 07:32 PM
  2. certificate java
    By dew1 in forum NetBeans
    Replies: 0
    Last Post: 06-25-2011, 07:23 AM
  3. Replies: 0
    Last Post: 10-06-2010, 07:58 PM
  4. Replies: 5
    Last Post: 06-26-2009, 03:03 AM
  5. Java certificate
    By Nick15 in forum Java Certification
    Replies: 2
    Last Post: 11-12-2007, 07:02 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts