Search in sources :

Example 1 with CertificateInfo

use of com.vmware.photon.controller.model.support.CertificateInfo in project photon-model by vmware.

the class X509TrustManagerResolver method getCertificateInfoServiceErrorResponse.

/**
 * @return {@link CertificateInfoServiceErrorResponse} for the untrusted certificate or {@code
 * null} if the resolver was not called or the certificate is trusted
 */
public CertificateInfoServiceErrorResponse getCertificateInfoServiceErrorResponse() {
    if (this.connectionCertificates.isEmpty()) {
        return null;
    }
    X509Certificate[] chain = getCertificateChain();
    String certificate = CertificateUtil.toPEMformat(chain);
    Map<String, String> certProps = CertificateUtil.getCertificateInfoProperties(chain[0]);
    CertificateInfo certificateInfo = CertificateInfo.of(certificate, certProps);
    CertificateException certException = getCertificateException();
    return CertificateInfoServiceErrorResponse.create(certificateInfo, Operation.STATUS_CODE_UNAVAILABLE, CertificateInfoServiceErrorResponse.ERROR_CODE_UNTRUSTED_CERTIFICATE, certException.getCause());
}
Also used : CertificateInfo(com.vmware.photon.controller.model.support.CertificateInfo) CertificateException(java.security.cert.CertificateException) X509Certificate(java.security.cert.X509Certificate)

Aggregations

CertificateInfo (com.vmware.photon.controller.model.support.CertificateInfo)1 CertificateException (java.security.cert.CertificateException)1 X509Certificate (java.security.cert.X509Certificate)1