Search code examples
javax509certificatepki

Access certificate signature from a certificate


I'm working on a project where i need the digital signature to proceed further.I tried all the built in methods,bt sadly,nothing worked!

This is what i want to extract:

Algorithm: [SHA512withRSA] Signature: 0000: 60 3B FA 8C 49 CF 97 E3 8B 04 F6 FD 75 23 5D 96 `;..I.......u#]. 0010: E0 17 C4 10 03 FC 90 B9 9B 4C 00 43 C0 5A F5 08 .........L.C.Z.. 0020: 93 0A 38 FA 13 42 39 B7 CE 27 DE 47 01 FB 0F EB ..8..B9..'.G.... 0030: 28 FB 59 FA FD 04 70 A6 A5 E1 4D 59 5D 03 3C 2E (.Y...p...MY].<. 0040: 5B 9B 03 3B 2A 16 2B 72 0D 58 20 93 8D C6 77 92 [..;*.+r.X ...w. 0050: D3 A9 D3 AA 0F 02 69 77 94 F4 FA 3F 02 21 34 53 ......iw...?.!4S 0060: 00 96 24 5C 67 5A 80 61 89 5D 0F AA 74 63 1A EF ..$\gZ.a.]..tc.. 0070: A1 98 EC 7C A8 52 D8 F5 42 10 18 4F 4D 66 98 FA .....R..B..OMf..

Please help me out...


Solution

  • I know you say the built in methods don't work, but that's not very useful. How are they not working? And what does your code look like?

    You should be able to load the certificate using a CertificateFactory, then cast it to an X.509 certificate. From there, the getSignature() method returns a byte array containing the signature and getSigAlgName() returns the algorithm used to compute the signature. All of this is pretty well documented in the Java API documents: http://docs.oracle.com/javase/7/docs/api/java/security/cert/X509Certificate.html