Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;

public class Main {
    /**
     * populate X509Certificate from a certificate file at the certFilePath
     */
    public static X509Certificate getX509(String certFilePath) throws CertificateException, FileNotFoundException {
        CertificateFactory cf = CertificateFactory.getInstance("X.509");
        FileInputStream in = new FileInputStream(certFilePath);
        return (X509Certificate) cf.generateCertificate(in);
    }
}