use of org.bouncycastle.pkcs.PKCS10CertificationRequest in project athenz by yahoo.
the class ZTSUtilsTest method testVerifyCertificateRequestMismatchDns.
@Test
public void testVerifyCertificateRequestMismatchDns() throws IOException {
Path path = Paths.get("src/test/resources/athenz.mismatch.cn.csr");
String csr = new String(Files.readAllBytes(path));
PKCS10CertificationRequest certReq = Crypto.getPKCS10CertRequest(csr);
boolean result = ZTSUtils.verifyCertificateRequest(certReq, "athenz2", "production");
assertFalse(result);
}
use of org.bouncycastle.pkcs.PKCS10CertificationRequest in project athenz by yahoo.
the class ZTSUtilsTest method testValidateCertReqInstanceIdInvalid.
@Test
public void testValidateCertReqInstanceIdInvalid() throws IOException {
Path path = Paths.get("src/test/resources/invalid_dns.csr");
String csr = new String(Files.readAllBytes(path));
PKCS10CertificationRequest certReq = Crypto.getPKCS10CertRequest(csr);
boolean result = ZTSUtils.validateCertReqInstanceId(certReq, "1001");
assertFalse(result);
}
use of org.bouncycastle.pkcs.PKCS10CertificationRequest in project athenz by yahoo.
the class CryptoTest method testExtractX509CSRFieldsWithOU.
@Test
public void testExtractX509CSRFieldsWithOU() throws IOException {
Path path = Paths.get("src/test/resources/multiple_ips.csr");
String csr = new String(Files.readAllBytes(path));
PKCS10CertificationRequest certReq = Crypto.getPKCS10CertRequest(csr);
assertNotNull(certReq);
assertEquals(Crypto.extractX509CSRSubjectOUField(certReq), "Testing Domain");
}
use of org.bouncycastle.pkcs.PKCS10CertificationRequest in project athenz by yahoo.
the class CryptoTest method testGenerateX509CertificateReqPrivateKey.
@Test
public void testGenerateX509CertificateReqPrivateKey() throws IOException {
Path path = Paths.get("src/test/resources/valid.csr");
String certStr = new String(Files.readAllBytes(path));
PKCS10CertificationRequest certReq = Crypto.getPKCS10CertRequest(certStr);
X509Certificate caCertificate = Crypto.loadX509Certificate(ecPublicX509Cert);
PrivateKey caPrivateKey = Crypto.loadPrivateKey(rsaPrivateKey);
X509Certificate cert = Crypto.generateX509Certificate(certReq, caPrivateKey, caCertificate, 600, false);
assertNotNull(cert);
assertEquals(cert.getIssuerX500Principal().getName(), "CN=athenz.syncer,O=My Test Company,L=Sunnyvale,ST=CA,C=US");
}
use of org.bouncycastle.pkcs.PKCS10CertificationRequest in project athenz by yahoo.
the class CryptoTest method testGenerateX509CertificateInvalid.
@Test
public void testGenerateX509CertificateInvalid() throws IOException {
Path path = Paths.get("src/test/resources/valid.csr");
String certStr = new String(Files.readAllBytes(path));
PKCS10CertificationRequest certReq = Crypto.getPKCS10CertRequest(certStr);
PrivateKey caPrivateKey = Crypto.loadPrivateKey(rsaPrivateKey);
try {
Crypto.generateX509Certificate(certReq, caPrivateKey, (X500Name) null, 600, true);
fail();
} catch (CryptoException ex) {
assertTrue(true, "Caught excepted exception");
}
}
Aggregations