Search in sources :

Example 1 with SimpleCertificateAuthority

use of org.platformlayer.crypto.SimpleCertificateAuthority in project platformlayer by platformlayer.

the class PkiServiceImpl method signCsr.

@Override
public List<X509Certificate> signCsr(ProjectEntity project, String csr) throws OpsException {
    CertificateAndKey projectPki;
    try {
        projectPki = repository.getProjectPki(project);
    } catch (RepositoryException e) {
        throw new OpsException("Error getting project PKI info", e);
    }
    SimpleCertificateAuthority ca = new SimpleCertificateAuthority();
    ca.caCertificate = projectPki.getCertificateChain();
    ca.caPrivateKey = projectPki.getPrivateKey();
    X509Certificate certificate = ca.signCsr(csr);
    List<X509Certificate> chain = Lists.newArrayList();
    chain.add(certificate);
    for (X509Certificate cert : projectPki.getCertificateChain()) {
        chain.add(cert);
    }
    return chain;
}
Also used : OpsException(org.platformlayer.ops.OpsException) SimpleCertificateAuthority(org.platformlayer.crypto.SimpleCertificateAuthority) RepositoryException(org.platformlayer.RepositoryException) CertificateAndKey(com.fathomdb.crypto.CertificateAndKey) X509Certificate(java.security.cert.X509Certificate)

Aggregations

CertificateAndKey (com.fathomdb.crypto.CertificateAndKey)1 X509Certificate (java.security.cert.X509Certificate)1 RepositoryException (org.platformlayer.RepositoryException)1 SimpleCertificateAuthority (org.platformlayer.crypto.SimpleCertificateAuthority)1 OpsException (org.platformlayer.ops.OpsException)1