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());
}
Aggregations