Skip to content

Commit

Permalink
[INJIVER-587] - add base64 decode for pem string
Browse files Browse the repository at this point in the history
Signed-off-by: Sreenadh S <[email protected]>
  • Loading branch information
sree96 committed Dec 20, 2024
1 parent 45ea8b0 commit e6bf2aa
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.security.SecureRandom;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.X509EncodedKeySpec;
import java.util.Base64;

public class SecurityUtils {

Expand All @@ -28,8 +29,9 @@ public static String generateNonce()
}

public static RSAPublicKey readX509PublicKey(String pem) throws Exception {
String decodedPem = new String(Base64.getDecoder().decode(pem));
KeyFactory factory = KeyFactory.getInstance("RSA");
PemReader pemReader = new PemReader(new StringReader(pem));
PemReader pemReader = new PemReader(new StringReader(decodedPem));
PemObject pemObject = pemReader.readPemObject();
byte[] content = pemObject.getContent();
X509EncodedKeySpec pubKeySpec = new X509EncodedKeySpec(content);
Expand Down

0 comments on commit e6bf2aa

Please sign in to comment.