Code example for Certificate

Methods: getPublicKey

0
            if (key instanceof PrivateKey) {
                // Get certificate of public key 
                Certificate cert = keystore.getCertificate(alias);
     
                // Get public key 
                PublicKey publicKey = cert.getPublicKey();
     
                // Return a key pair 
                return new KeyPair(publicKey, (PrivateKey)key);
            } 
        } catch (UnrecoverableKeyException e) {
        } catch (NoSuchAlgorithmException e) {
        } catch (KeyStoreException e) {
        } 
        return null; 
    } 
  
}