I am trying to get an RSAPublicKey object from a public key file which is PEM encoded . The file is in the format given below
-----BEGIN PUBLIC KEY-----
M67sdjFDSSTRWE%$HGF£$"F£$$£%$ etc...
-----END PUBLIC KEY-----enter code here
I would like to get the modulus and exponent by reading this file. I have tried to do base64 decode and used the following
RSAPublicKey rsakey = (RSAPublicKey)PublicKeyDecoder.decode(decoded, "X509");
but it throws an InvalidKeyEncodingException
.
Is there any way I can get an RSAPublicKey object from a PEM encoded public key file?