Search in sources :

Example 1 with KeystoreRequest

use of com.venafi.vcert.sdk.connectors.cloud.endpoint.KeystoreRequest in project vcert-java by Venafi.

the class CloudConnector method retrieveCertificateAsPemCollectionFromCSRServiceGenerated.

private PEMCollection retrieveCertificateAsPemCollectionFromCSRServiceGenerated(CertificateRequest request, byte[] serverPublicKey, String chainOption) throws VCertException {
    String encodedMessage = null;
    try {
        byte[] cipherText = SealedBoxUtility.cryptoBoxSeal(serverPublicKey, request.keyPassword().getBytes());
        encodedMessage = Base64.getEncoder().encodeToString(cipherText);
    } catch (Exception e) {
        throw new VCertException(e);
    }
    KeystoreRequest keystoreRequest = new KeystoreRequest().exportFormat("PEM").encryptedPrivateKeyPassphrase(encodedMessage).encryptedKeystorePassphrase("").certificateLabel("");
    InputStream keyStoreAsStream = null;
    try {
        Response response = cloud.retrieveKeystore(request.certId(), keystoreRequest, auth.apiKey());
        keyStoreAsStream = response.body().asInputStream();
    } catch (IOException e) {
        throw new VCertException(e);
    }
    return CloudConnectorUtils.getPEMCollectionFromKeyStoreAsStream(keyStoreAsStream, request.certId(), request.chainOption(), request.keyPassword(), request.dataFormat());
}
Also used : ImportResponse(com.venafi.vcert.sdk.certificate.ImportResponse) Response(feign.Response) VCertException(com.venafi.vcert.sdk.VCertException) InputStream(java.io.InputStream) KeystoreRequest(com.venafi.vcert.sdk.connectors.cloud.endpoint.KeystoreRequest) IOException(java.io.IOException) VCertException(com.venafi.vcert.sdk.VCertException) ConnectorException(com.venafi.vcert.sdk.connectors.ConnectorException) IOException(java.io.IOException)

Aggregations

VCertException (com.venafi.vcert.sdk.VCertException)1 ImportResponse (com.venafi.vcert.sdk.certificate.ImportResponse)1 ConnectorException (com.venafi.vcert.sdk.connectors.ConnectorException)1 KeystoreRequest (com.venafi.vcert.sdk.connectors.cloud.endpoint.KeystoreRequest)1 Response (feign.Response)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1