@@ -6,7 +6,8 @@ VCert is a Java library, SDK, designed to simplify key generation and enrollment
66(also known as SSL/TLS certificates and keys) that comply with enterprise security policy by using the
77[ Venafi Platform] ( https://www.venafi.com/platform/trust-protection-platform ) or [ Venafi Cloud] ( https://pki.venafi.com/venafi-cloud/ ) .
88
9-
9+ #### Compatibility
10+ VCert releases are tested using the latest version of Trust Protection Platform. The [ latest VCert release] ( ../../releases/latest ) should be compatible with Trust Protection Platform 17.3 or higher based on the subset of API methods it consumes.
1011
1112## Installation
1213
@@ -19,71 +20,103 @@ mvn install
1920
2021## Usage
2122
22- A basic example of createing a certificate using the VCert java implementation.
23+ A basic example of creating a certificate using VCert Java:
2324
2425```
25- final Config config = Config.builder()
26- .connectorType(ConnectorType.CLOUD)
27- .zone("Default")
28- .build();
29-
30- final VCertClient client = new VCertClient(config);
31- final Authentication auth = Authentication.builder()
32- .apiKey("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
33- .build();
34-
35- client.authenticate(auth);
36- final ZoneConfiguration zoneConfiguration = client.readZoneConfiguration("Public");
37-
38-
39-
40- // Generate a certificate
41- CertificateRequest certificateRequest = new CertificateRequest().subject(
42- new CertificateRequest.PKIXName()
43- .commonName("opencredo.test")
44- .organization(Collections.singletonList("Venafi, Inc."))
45- .organizationalUnit(Arrays.asList("Engineering"))
46- .country(Collections.singletonList("US"))
47- .locality(Collections.singletonList("SLC"))
48- .province(Collections.singletonList("Utah")))
49-
50- .keyType(KeyType.RSA);
51- certificateRequest = client.generateRequest(zoneConfiguration, certificateRequest);
52-
53-
54- // Submit the certificate request
55- String newCertId = client.requestCertificate(certificateRequest, "Default");
56-
57-
58- // Retrieve PEM collection from Venafi
59- final CertificateRequest pickupRequest = new CertificateRequest().pickupId(newCertId);
60- PEMCollection pemCollection = client.retrieveCertificate(pickupRequest);
61- System.out.println(pemCollection.certificate());
62-
63- // Renew the certificate
64- X509Certificate cert = (X509Certificate) pemCollection.certificate();
65- String thumbprint = DigestUtils.sha1Hex(cert.getEncoded()).toUpperCase();
66- final CertificateRequest certificateRequestToRenew = new CertificateRequest().subject(
67- new CertificateRequest.PKIXName()
68- .commonName("opencredo.test")
69- .organization(Collections.singletonList("Venafi, Inc."))
70- .organizationalUnit(Arrays.asList("Engineering"))
71- .country(Collections.singletonList("US"))
72- .locality(Collections.singletonList("SLC"))
73- .province(Collections.singletonList("Utah")));
74-
75- client.generateRequest(zoneConfiguration, certificateRequestToRenew);
76-
77- final RenewalRequest renewalRequest = new RenewalRequest()
78- .thumbprint(thumbprint)
79- .request(certificateRequestToRenew);
80- final String renewedCertificate = client.renewCertificate(renewalRequest);
81-
82- // Retrieve PEM collection from Venafi
83- final CertificateRequest renewPickupRequest = new CertificateRequest().pickupId(renewedCertificate);
84- PEMCollection pemCollectionRenewed = client.retrieveCertificate(pickupRequest);
85- System.out.println(pemCollectionRenewed.certificate());
86-
26+ final Config config = Config.builder()
27+ .connectorType(ConnectorType.TPP)
28+ .baseUrl("https://tpp.venafi.example/vedsdk")
29+ .build();
30+
31+ /* or for Venafi Cloud
32+ final Config config = Config.builder()
33+ .connectorType(ConnectorType.CLOUD)
34+ .build();
35+ */
36+
37+ final VCertClient client = new VCertClient(config);
38+
39+ final Authentication auth = Authentication.builder()
40+ .user("local:apiuser")
41+ .password("password")
42+ .build();
43+
44+ /* or for Venafi Cloud
45+ final Authentication auth = Authentication.builder()
46+ .apiKey("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
47+ .build();
48+ */
49+
50+ client.authenticate(auth);
51+
52+ //////////////////////////////////////
53+ ///// Local Generated CSR - RSA //////
54+ //////////////////////////////////////
55+
56+ // Generate a key pair and certificate signing request
57+ CertificateRequest certificateRequest = new CertificateRequest().subject(
58+ new CertificateRequest.PKIXName()
59+ .commonName("vcert-java.venafi.example")
60+ .organization(Collections.singletonList("Example Company"))
61+ .organizationalUnit(Arrays.asList("Example Division"))
62+ .country(Collections.singletonList("US"))
63+ .locality(Collections.singletonList("Salt Lake City"))
64+ .province(Collections.singletonList("Utah")))
65+ .dnsNames(Arrays.asList("alfa.venafi.example", "bravo.venafi.example", "charlie.venafi.example"))
66+ .ipAddresses(Arrays.asList(InetAddress.getByName("10.20.30.40"),InetAddress.getByName("172.16.172.16")))
67+ .emailAddresses(Arrays.asList("larry@venafi.example", "moe@venafi.example", "curly@venafi.example"))
68+ .keyType(KeyType.RSA);
69+
70+ ZoneConfiguration zoneConfiguration = client.readZoneConfiguration("Certificates\\VCert");
71+ certificateRequest = client.generateRequest(zoneConfiguration, certificateRequest);
72+
73+ // Submit the certificate request
74+ client.requestCertificate(certificateRequest, "Certificates\\VCert");
75+
76+ // Retrieve PEM collection from Venafi
77+ PEMCollection pemCollection = client.retrieveCertificate(certificateRequest);
78+
79+ System.out.println(pemCollection.pemPrivateKey());
80+ System.out.println(pemCollection.pemCertificate());
81+ System.out.println(pemCollection.pemCertificateChain());
82+
83+ /////////////////////////////
84+ ///// User Provided CSR /////
85+ /////////////////////////////
86+
87+ String csr = "-----BEGIN CERTIFICATE REQUEST-----\n" +
88+ "MIIC8DCCAdgCAQAwgY4xCzAJBgNVBAYTAlVTMQ0wCwYDVQQIEwRVdGFoMRcwFQYD\n" +
89+ "VQQHEw5TYWx0IExha2UgQ2l0eTEYMBYGA1UEChMPRXhhbXBsZSBDb21wYW55MRkw\n" +
90+ "FwYDVQQLExBFeGFtcGxlIERpdmlzaW9uMSIwIAYDVQQDExl2Y2VydC1qYXZhLnZl\n" +
91+ "bmFmaS5leGFtcGxlMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA9PHk\n" +
92+ "bR5i0pV6M08XXi+Z0tAJkIU3TLG0Hr0n5tY6JIcP3Sc8wrodgMN66WUP6oLV/yqR\n" +
93+ "2lKom+dc9dIN9iaVUfnpPwhjyuIMyd0svmU2hnZj3InG5kvqnMnzQvRfWx0OKmMB\n" +
94+ "c652qZsgR3d6I+YufhIsuMxkWMev2njXGZAnThGVMv/iD9dLTO+0lTwwSbvM1lxw\n" +
95+ "YxAwdVFX1+vl0ORyOs4OUqUFv3i6qvS/U/RI45TrgR+XA2/8xPlo5gfGrnFfiyJJ\n" +
96+ "jMctOak2mOVrR/2kXYcOw+37zkpJEADSZBgm/YzqdYtrI8t/M4uClkn9WQgTijC1\n" +
97+ "eN4hFKyTGeOGIqKI/QIDAQABoBwwGgYJKoZIhvcNAQkOMQ0wCzAJBgNVHRMEAjAA\n" +
98+ "MA0GCSqGSIb3DQEBCwUAA4IBAQDOxsP3fFsx/UOLudVm6MAuAFZfZxm7P1sZrYhb\n" +
99+ "tgshSXDlruiO7/ovb8rDrRrKJjAx4+tXlQRsDfxIpvuNcAd7//WCjjIfAoNlGRW4\n" +
100+ "cMtWfvCN1p7XsVer+JJHtM5UZ+oKS06hdPppDP4rfjyhTM5Y0M8JAgMcGsm7lrWU\n" +
101+ "w1ly6k8k5NzadWGOZwvz75qrn0ufHuI96sPsL5wmqty34BfnBy4iMddU3m/Y1qQb\n" +
102+ "VfKV2CRWybwV/QeCtogXvI7Nou2LZQDWI57498Nzif1Zvfy0/ab8XBkX2vMUXcnm\n" +
103+ "1A7/9ezwgYTZvy1rbBSKBSjAx/MAOPUM93OcjT6tKtEeEnI8\n" +
104+ "-----END CERTIFICATE REQUEST-----";
105+
106+ certificateRequest = new CertificateRequest().csr(csr.getBytes())
107+ .csrOrigin(com.venafi.vcert.sdk.certificate.CsrOriginOption.UserProvidedCSR)
108+ .dnsNames(Arrays.asList("alfa.venafi.example", "bravo.venafi.example", "charlie.venafi.example"))
109+ .ipAddresses(Arrays.asList(InetAddress.getByName("10.20.30.40"),InetAddress.getByName("172.16.172.16")))
110+ .emailAddresses(Arrays.asList("larry@venafi.example", "moe@venafi.example", "curly@venafi.example"));
111+
112+ // Submit the certificate request
113+ client.requestCertificate(certificateRequest, "Certificates\\VCert");
114+
115+ // Retrieve PEM collection from Venafi
116+ pemCollection = client.retrieveCertificate(certificateRequest);
117+
118+ System.out.println(pemCollection.pemCertificate());
119+ System.out.println(pemCollection.pemCertificateChain());
87120
88121```
89122
@@ -131,7 +164,7 @@ mvn "-Dtest=*AT" test
1311644 . Implement and test your changes
1321655 . Commit your changes (` git commit -am 'Added some cool functionality' ` )
1331666 . Push to the branch (` git push origin your-branch-name ` )
134- 7 . Create a new Pull Request (https://github.com/youracct/vcert-java/pull/new/working -branch )
167+ 7 . Create a new Pull Request (https://github.com/youracct/vcert-java/pull/new/your -branch-name )
135168
136169
137170## License
0 commit comments