+ checkCertLogin(c, pk, scookie, 200);
+ checkCertLogin(c, pk, cookie, 302);
+ }
+
+ @Test
+ public void testSerialSteal() throws IOException, GeneralSecurityException, SQLException, InterruptedException, GigiApiException {
+ String mail = "thisgo" + createUniqueName() + "@example.com";
+ int user = createAssuranceUser("test", "tugo", mail, TEST_PASSWORD);
+ KeyPair kp = generateKeypair();
+ String csr = generatePEMCSR(kp, "CN=hans");
+ User u = User.getById(user);
+ Certificate c = new Certificate(u, u, Certificate.buildDN("CN", "hans"), Digest.SHA256, csr, CSRType.CSR, CertificateProfile.getById(1));
+ Certificate c2 = new Certificate(u, u, Certificate.buildDN("CN", "hans"), Digest.SHA256, csr, CSRType.CSR, CertificateProfile.getById(1));
+ final PrivateKey pk = kp.getPrivate();
+ Job j1 = c.issue(null, "2y", u);
+ c2.issue(null, "2y", u).waitFor(60000);
+ j1.waitFor(60000);
+ final X509Certificate ce = c.cert();
+ String scookie = login(pk, ce);
+
+ checkCertLogin(c, pk, scookie, 200);
+ checkCertLogin(c2, pk, scookie, 403);
+ checkCertLogin(c, pk, scookie, 302);
+
+ }
+
+ private void checkCertLogin(Certificate c2, final PrivateKey pk, String scookie, int expected) throws IOException, NoSuchAlgorithmException, KeyManagementException, GeneralSecurityException {