Exemplo n.º 1
0
 public void createIntermediateCert() throws StorageException, CertificateException {
   PEMFileStore<PKCS10CertificationRequest> interrequeststore =
       new PEMFileStore<PKCS10CertificationRequest>("D:\\certs\\inter.req");
   PEMFileStore<X509Certificate> intercertstore =
       new PEMFileStore<X509Certificate>("D:\\certs\\inter.crt");
   PKCS10CertificationRequest request = interrequeststore.read();
   X509Certificate parentcert = certstore.read();
   KeyPair parentkey = keystore.read();
   X509Certificate certificate = ca.issueCertificate(request, 365, parentcert, parentkey, true);
   intercertstore.save(certificate, null);
 }
Exemplo n.º 2
0
 /**
  * Step 4,利用中间证书签发客户证书
  *
  * @throws StorageException
  * @throws CertificateException
  */
 public void createClientCert() throws StorageException, CertificateException {
   PEMFileStore<PKCS10CertificationRequest> clientrequeststore =
       new PEMFileStore<PKCS10CertificationRequest>("D:\\certs\\client.req");
   PEMFileStore<KeyPair> serverkeystore = new PEMFileStore<KeyPair>("D:\\certs\\server.key");
   PEMFileStore<X509Certificate> servercertstore =
       new PEMFileStore<X509Certificate>("D:\\certs\\server.crt");
   PEMFileStore<X509Certificate> clientcertstore =
       new PEMFileStore<X509Certificate>("D:\\certs\\client.crt");
   PKCS10CertificationRequest request = clientrequeststore.read();
   X509Certificate parentcert = servercertstore.read();
   KeyPair parentkey = serverkeystore.read();
   X509Certificate certificate = ca.issueCertificate(request, 365, parentcert, parentkey, true);
   clientcertstore.save(certificate, null);
 }
Exemplo n.º 3
0
  public void createEmployeeCert() throws StorageException, CertificateException {
    PEMFileStore<PKCS10CertificationRequest> employeerequeststore =
        new PEMFileStore<PKCS10CertificationRequest>("D:\\certs\\employee.req");
    PEMFileStore<X509Certificate> employeecertstore =
        new PEMFileStore<X509Certificate>("D:\\certs\\employee.crt");
    PEMFileStore<X509Certificate> clientcertstore =
        new PEMFileStore<X509Certificate>("D:\\certs\\client.crt");
    PEMFileStore<KeyPair> clientkeystore = new PEMFileStore<KeyPair>("D:\\certs\\client.key");
    PKCS10CertificationRequest request = employeerequeststore.read();
    X509Certificate parentcert = clientcertstore.read();
    KeyPair parentkey = clientkeystore.read();
    X509Certificate certificate = ca.issueCertificate(request, 365, parentcert, parentkey, false);

    employeecertstore.save(certificate, null);
  }