certs-client

Java API for Certificate Web Service.

Лицензия

Лицензия

Категории

Категории

CLI Взаимодействие с пользователем
Группа

Группа

com.oneops
Идентификатор

Идентификатор

certs-client
Последняя версия

Последняя версия

1.1.4
Дата

Дата

Тип

Тип

jar
Описание

Описание

certs-client
Java API for Certificate Web Service.
Организация-разработчик

Организация-разработчик

Walmart, Inc.

Скачать certs-client

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.oneops/certs-client/ -->
<dependency>
    <groupId>com.oneops</groupId>
    <artifactId>certs-client</artifactId>
    <version>1.1.4</version>
</dependency>
// https://jarcasting.com/artifacts/com.oneops/certs-client/
implementation 'com.oneops:certs-client:1.1.4'
// https://jarcasting.com/artifacts/com.oneops/certs-client/
implementation ("com.oneops:certs-client:1.1.4")
'com.oneops:certs-client:jar:1.1.4'
<dependency org="com.oneops" name="certs-client" rev="1.1.4">
  <artifact name="certs-client" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.oneops', module='certs-client', version='1.1.4')
)
libraryDependencies += "com.oneops" % "certs-client" % "1.1.4"
[com.oneops/certs-client "1.1.4"]

Зависимости

compile (8)

Идентификатор библиотеки Тип Версия
com.squareup.retrofit2 : retrofit jar 2.4.0
com.squareup.retrofit2 : converter-moshi jar 2.4.0
com.squareup.moshi : moshi jar 1.6.0
com.squareup.okhttp3 : okhttp-urlconnection jar 3.10.0
com.squareup.okhttp3 : logging-interceptor jar 3.10.0
com.google.auto.value : auto-value-annotations jar 1.6
org.bouncycastle : bcprov-jdk15on jar 1.59
org.slf4j : slf4j-simple jar 1.7.25

provided (4)

Идентификатор библиотеки Тип Версия
com.google.auto.value : auto-value jar 1.6
com.ryanharter.auto.value : auto-value-moshi jar 0.4.5
com.squareup.auto.value : auto-value-redacted jar 1.0.1
com.google.code.findbugs : jsr305 jar 3.0.2

test (3)

Идентификатор библиотеки Тип Версия
org.junit.jupiter : junit-jupiter-api jar 5.2.0
org.junit.jupiter : junit-jupiter-params jar 5.2.0
com.squareup.okhttp3 : mockwebserver jar 3.10.0

Модули Проекта

Данный проект не имеет модулей.

Cert Certificate Web Service Client

Maven Central changelog javadoc

A java API for Certificate Web Service.

Download

Download the latest JAR or grab via Maven:

<dependency>
  <groupId>com.oneops</groupId>
  <artifactId>certs-client</artifactId>
  <version>1.1.4</version>
</dependency>

Examples

Initializing CWS Client

CwsClient client = CwsClient.builder()
            .endPoint("Api Endpoint") 
            .appId("App ID")               
            .teamDL("Base Team DL")             
            .keystore("Keystore Path")
            .keystorePassword("Keystore password")
            .build();
  • Keystore should be of type PKCS#12 format.
  • For loading the keystore from classpath use, classpath:/<your/cws/keystore/path>.p12
  • If the keystore contains multiple cert entries, use .keyAlias("cws-client-key") to select the proper client private key.
  • To enable http debugging for troubleshooting, set .debug(true) to the CwsClient.builder()
  • In order to create a PKCS#12(.p12) keystore from PEM/DER encoded certificate, use the following openssl command.
$ openssl pkcs12 -export -chain -out cws-keystore.p12 -inkey private.key -password pass:test123 \
                  -in client.crt -certfile client.crt -CAfile cacert.crt -name cws-client-key \
                  -caname root-ca
              
# Add trust-store entry (cacert.crt) to the keystore.
$ keytool -importcert -trustcacerts -alias root-ca -storetype PKCS12 \
                       -keystore cws-keystore.p12 -storepass test123 -file cacert.crt
                   
# View pkcs12 keystore details                   
$ openssl pkcs12 -info -password pass:test123 -in cws-keystore.p12 
# keytool -list  -storepass test123 -keystore cws-keystore.p12 -v                

Create new certificate

String cn = "test1.domain.com" ;
String teamDL = "test-teamDL"; // Relative to Base TeamDL.
List<String> sans = Arrays.asList("app1.domain.com","app2.domain.com");
    
String certName = client.createCert(cn,sans, teamDL);

Check certificate exists

boolean exists = client.certExists(cn, teamDL);

Download certificate

  • Download the private key, certificate and it's trust chain as PKCS#12 format.

    // Generate Keystore/key password (Optional)
    String keystorePasswd = PasswordGen.builder().build().generate(20); 
    String base64Content = client.downloadCert(cn, teamDL, keystorePasswd, CertFormat.PKCS12);
  • Download CertBundle, which contains encrypted PKCS#8 private key, client cert and cacerts.

    // Private key password should be at-least 4 chars.
     CertBundle certBundle = client.downloadCert(cn, teamDL, Optional.of("test123"));
    // certBundle.key() 
    // certBundle.keyPassword() 
    // certBundle.cert()
    // certBundle.cacert()
  • Download CertBundle which contains encrypted PKCS#1 private key, client cert and cacerts.

     CertBundle certBundle = client.downloadCert(cn, teamDL, Optional.empty());
    // certBundle.key() 
    // certBundle.cert()
    // certBundle.cacert()

Get certificate expiration date

LocalDateTime date = client.getCertExpirationDate(cn, teamDL);

View certificate details

ViewRes viewRes = client.viewCert(cn, teamDL);

Revoke and disable the certificate

RevokeRes revokeRes = client.revokeCert(cn, teamDL, RevokeReason.NONE, true);

Renew certificate

boolean success = client.renewCert(cn, teamDL);

Delete certificate

client.obsoleteCert(cn, teamDL);

Testing

Set the following env variables and run ./mvnw clean test to execute the unit tests.

 export cws_host=...     
 export cws_app_id=...
 export cws_team_dl=....
 export cws_domain=...
 export cws_keystore=.....p12
 export cws_keystore_pass=....

Dependencies

License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
com.oneops

OneOps

Application Lifecycle Management of Cloud Based Workloads

Версии библиотеки

Версия
1.1.4
1.1.3
1.1.2
1.1.1
1.1.0
1.0.0