Skip to content

Instantly share code, notes, and snippets.

@RyanGDay
RyanGDay / gist:9af0d0ba3bf5304167b6a2885c161b35
Created February 10, 2021 16:00
Conversion of AzurePublicKey to PublicKey
private PublicKey convertKey(AzurePublicKey azKey) {
PublicKey publicKey = null;
BigInteger modulus = new BigInteger(1, Base64.getUrlDecoder().decode(azKey.getN()));
BigInteger exponent = new BigInteger(1, Base64.getUrlDecoder().decode(azKey.getE()));
try {
publicKey = KeyFactory.getInstance("RSA").generatePublic(new RSAPublicKeySpec(modulus, exponent));
// load cert