use of org.bouncycastle.pkcs.PKCS10CertificationRequest in project athenz by yahoo.
the class ZTSUtilsTest method testValidateCertReqInstanceId.
@Test
public void testValidateCertReqInstanceId() throws IOException {
Path path = Paths.get("src/test/resources/athenz.instanceid.csr");
String csr = new String(Files.readAllBytes(path));
PKCS10CertificationRequest certReq = Crypto.getPKCS10CertRequest(csr);
boolean result = ZTSUtils.validateCertReqInstanceId(certReq, "1001");
assertTrue(result);
result = ZTSUtils.validateCertReqInstanceId(certReq, "10012");
assertFalse(result);
}
use of org.bouncycastle.pkcs.PKCS10CertificationRequest in project athenz by yahoo.
the class ZTSUtilsTest method testVerifyCertificateRequestNoCertRecord.
@Test
public void testVerifyCertificateRequestNoCertRecord() throws IOException {
Path path = Paths.get("src/test/resources/athenz.instanceid.csr");
String csr = new String(Files.readAllBytes(path));
PKCS10CertificationRequest certReq = Crypto.getPKCS10CertRequest(csr);
boolean result = ZTSUtils.verifyCertificateRequest(certReq, "athenz", "production");
assertTrue(result);
result = ZTSUtils.verifyCertificateRequest(certReq, "athenz2", "production");
assertFalse(result);
}
use of org.bouncycastle.pkcs.PKCS10CertificationRequest in project athenz by yahoo.
the class ZTSUtilsTest method testValidateCertReqDNSNamesSubdomainInvalid.
@Test
public void testValidateCertReqDNSNamesSubdomainInvalid() throws IOException {
Path path = Paths.get("src/test/resources/subdomain_invalid.csr");
String csr = new String(Files.readAllBytes(path));
PKCS10CertificationRequest certReq = Crypto.getPKCS10CertRequest(csr);
boolean result = ZTSUtils.validateCertReqDNSNames(certReq, "athenz.domain", "production");
assertFalse(result);
}
use of org.bouncycastle.pkcs.PKCS10CertificationRequest in project athenz by yahoo.
the class ZTSClientTest method testGenerateInstanceRefreshRequestTopDomain.
@Test
public void testGenerateInstanceRefreshRequestTopDomain() {
File privkey = new File("./src/test/resources/unit_test_private_k0.pem");
PrivateKey privateKey = Crypto.loadPrivateKey(privkey);
InstanceRefreshRequest req = ZTSClient.generateInstanceRefreshRequest("coretech", "test", privateKey, "aws", 3600);
assertNotNull(req);
PKCS10CertificationRequest certReq = Crypto.getPKCS10CertRequest(req.getCsr());
assertEquals("coretech.test", Crypto.extractX509CSRCommonName(certReq));
assertEquals("test.coretech.aws.athenz.cloud", Crypto.extractX509CSRDnsNames(certReq).get(0));
}
use of org.bouncycastle.pkcs.PKCS10CertificationRequest in project athenz by yahoo.
the class ZTSClientTest method testGenerateRoleCertificateRequest.
@Test
public void testGenerateRoleCertificateRequest() {
File privkey = new File("./src/test/resources/unit_test_private_k0.pem");
PrivateKey privateKey = Crypto.loadPrivateKey(privkey);
RoleCertificateRequest req = ZTSClient.generateRoleCertificateRequest("coretech", "test", "sports", "readers", privateKey, "aws", 3600);
assertNotNull(req);
PKCS10CertificationRequest certReq = Crypto.getPKCS10CertRequest(req.getCsr());
assertEquals(Crypto.extractX509CSRCommonName(certReq), "sports:role.readers");
assertEquals(Crypto.extractX509CSREmail(certReq), "coretech.test@aws.athenz.cloud");
List<String> uris = Crypto.extractX509CSRURIs(certReq);
assertEquals(uris.size(), 2);
assertEquals(uris.get(0), "spiffe://sports/ra/readers");
assertEquals(uris.get(1), "athenz://principal/coretech.test");
}
Aggregations