How to determine the length (in bits) of an X509 public key in Java?
I want to get the same value as the "Public key" when running "openssl x509 -in cert.crt -noout -text". For example:
Certificate:
Data:
Version: 3 (0x2)
Serial Number:
17:00:00:01:a2:41:4b:56:3e:99:ba:92:b5:00:02:00:00:01:a2
Signature Algorithm: sha256WithRSAEncryption
Issuer: DC=com, DC=magnicomp, CN=MagniComp Issuing CA
Validity
Not Before: Sep 14 17:23:18 2015 GMT
Not After : Sep 13 17:23:18 2016 GMT
Subject: CN=dim.magnicomp.com
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (2048 bit)
I have an X509Certificate object, and I played with the PublicKey value returned through getPublicKey(), but I cannot figure out how to determine the key length from this.
source
share