/** * Step 3,生成证书请求 * * @throws KeyPairException * @throws CertificateException * @throws StorageException */ public void createClientCSR() throws KeyPairException, CertificateException, StorageException { PEMFileStore<KeyPair> clientkeystore = new PEMFileStore<KeyPair>("D:\\certs\\client.key"); PEMFileStore<PKCS10CertificationRequest> clientrequeststore = new PEMFileStore<PKCS10CertificationRequest>("D:\\certs\\client.req"); KeyPair keypair = KeyPairManager.generateRSAKeyPair(); clientkeystore.save(keypair, null); X509Attrs principals = new X509Attrs(); principals.setCommonName("CRM平台根证书"); principals.setCountryCode("AU"); PKCS10CertificationRequest csr = CSRManager.generateCSR(keypair, principals); clientrequeststore.save(csr, null); }
/** * Step 6,生成证书请求 * * @throws KeyPairException * @throws CertificateException * @throws StorageException */ public void createServerCSR() throws KeyPairException, CertificateException, StorageException { PEMFileStore<KeyPair> serverkeystore = new PEMFileStore<KeyPair>("D:\\certs\\server.key"); PEMFileStore<PKCS10CertificationRequest> serverrequeststore = new PEMFileStore<PKCS10CertificationRequest>("D:\\certs\\server.req"); KeyPair keypair = KeyPairManager.generateRSAKeyPair(); serverkeystore.save(keypair, null); X509Attrs principals = new X509Attrs(); principals.setCommonName("*.zijincaifu.com"); principals.setCountryCode("CN"); PKCS10CertificationRequest csr = CSRManager.generateCSR(keypair, principals); serverrequeststore.save(csr, null); }
public void createEmployeeCSR() throws KeyPairException, StorageException, CertificateException { KeyPair keypair = KeyPairManager.generateRSAKeyPair(); PublicKey public1 = keypair.getPublic(); PEMFileStore<PublicKey> publicstore = new PEMFileStore<PublicKey>("D:\\certs\\employee.pub"); publicstore.save(public1, null); PEMFileStore<KeyPair> employeekeystore = new PEMFileStore<KeyPair>("D:\\certs\\employee.key"); employeekeystore.save(keypair, null); X509Attrs principals = new X509Attrs(); principals.setCommonName("CRM测试员工"); principals.setCountryCode("AU"); principals.setGiveName("E00001"); PKCS10CertificationRequest csr = CSRManager.generateCSR(keypair, principals); PEMFileStore<PKCS10CertificationRequest> employeerequeststore = new PEMFileStore<PKCS10CertificationRequest>("D:\\certs\\employee.req"); employeerequeststore.save(csr, null); }