Java Key Public getPublicKey(String certPath)

Here you can find the source of getPublicKey(String certPath)

Description

get Public Key

License

Open Source License

Declaration

public static PublicKey getPublicKey(String certPath) throws Exception 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.FileInputStream;
import java.io.InputStream;

import java.security.PublicKey;

import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;

public class Main {

    public static PublicKey getPublicKey(String certPath) throws Exception {
        Certificate cert = getCert(certPath);
        return cert.getPublicKey();
    }/*from  ww w  .j a  v  a2s . co  m*/

    public static Certificate getCert(String certPath) throws Exception {
        InputStream streamCert = new FileInputStream(certPath);
        CertificateFactory factory = CertificateFactory.getInstance("X.509");
        Certificate cert = factory.generateCertificate(streamCert);
        return cert;
    }
}

Related

  1. getPublicKey(KeyStore keyStore, String alias, char[] password)
  2. getPublicKey(KeyStore ks, String alias, char[] password)
  3. getPublicKey(String algo)
  4. getPublicKey(String alias)
  5. getPublicKey(String certificatePath)
  6. getPublicKey(String filename)
  7. getPublicKey(String filename)
  8. getPublicKey(String filename)
  9. getPublicKey(String key)