Search in sources :

Example 11 with Certificate

use of org.apache.cloudstack.framework.ca.Certificate in project cloudstack by apache.

the class RootCAProviderTest method testIssueCertificateWithoutCsr.

@Test
public void testIssueCertificateWithoutCsr() throws NoSuchProviderException, CertificateException, NoSuchAlgorithmException, InvalidKeyException, SignatureException {
    final Certificate certificate = provider.issueCertificate(Arrays.asList("domain1.com", "domain2.com"), null, 1);
    Assert.assertTrue(certificate != null);
    Assert.assertTrue(certificate.getPrivateKey() != null);
    Assert.assertEquals(certificate.getCaCertificates().get(0), caCertificate);
    Assert.assertEquals(certificate.getClientCertificate().getIssuerDN(), caCertificate.getIssuerDN());
    Assert.assertTrue(certificate.getClientCertificate().getNotAfter().before(new DateTime().plusDays(1).toDate()));
    certificate.getClientCertificate().verify(caCertificate.getPublicKey());
}
Also used : DateTime(org.joda.time.DateTime) X509Certificate(java.security.cert.X509Certificate) Certificate(org.apache.cloudstack.framework.ca.Certificate) Test(org.junit.Test)

Aggregations

Certificate (org.apache.cloudstack.framework.ca.Certificate)11 X509Certificate (java.security.cert.X509Certificate)7 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)5 IOException (java.io.IOException)3 Test (org.junit.Test)3 KeyPair (java.security.KeyPair)2 ArrayList (java.util.ArrayList)2 ActionEvent (com.cloud.event.ActionEvent)1 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)1 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)1 Host (com.cloud.host.Host)1 SSHKeyPairVO (com.cloud.user.SSHKeyPairVO)1 SSHCmdHelper (com.cloud.utils.ssh.SSHCmdHelper)1 StringReader (java.io.StringReader)1 InetAddress (java.net.InetAddress)1 KeyStoreException (java.security.KeyStoreException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 CertificateException (java.security.cert.CertificateException)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1