Here you can find the source of getPublicKey(KeyStore keyStore, String alias)
public static PublicKey getPublicKey(KeyStore keyStore, String alias)
//package com.java2s; import java.security.KeyStore; import java.security.KeyStoreException; import java.security.PublicKey; import java.security.cert.Certificate; public class Main { public static PublicKey getPublicKey(KeyStore keyStore, String alias) { return getCertificate(keyStore, alias).getPublicKey(); }//from w w w .j a va2 s . co m public static Certificate getCertificate(KeyStore keyStore, String alias) { try { return keyStore.getCertificate(alias); } catch (KeyStoreException e) { throw new RuntimeException("get certificate error.", e); } } }