X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=tests%2Fclub%2Fwpia%2Fgigi%2Fpages%2Faccount%2FTestCertificateAdd.java;h=21419d666ed6c96602bba76c278f0aefc78233c1;hp=0d83f301f0320db78b5717647f29609df5557017;hb=75c38b20dbfb17c78cd7af219761948295bb0ba3;hpb=76baa398052ef0f82828621be1357a92f30c13a4 diff --git a/tests/club/wpia/gigi/pages/account/TestCertificateAdd.java b/tests/club/wpia/gigi/pages/account/TestCertificateAdd.java index 0d83f301..21419d66 100644 --- a/tests/club/wpia/gigi/pages/account/TestCertificateAdd.java +++ b/tests/club/wpia/gigi/pages/account/TestCertificateAdd.java @@ -23,7 +23,6 @@ import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; import java.text.SimpleDateFormat; import java.util.Arrays; -import java.util.Base64; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; @@ -33,7 +32,6 @@ import java.util.regex.Pattern; import org.junit.Test; -import club.wpia.gigi.crypto.SPKAC; import club.wpia.gigi.dbObjects.CertificateOwner; import club.wpia.gigi.dbObjects.Digest; import club.wpia.gigi.pages.account.certs.CertificateAdd; @@ -56,7 +54,6 @@ import sun.security.x509.GeneralNameInterface; import sun.security.x509.GeneralNames; import sun.security.x509.RFC822Name; import sun.security.x509.SubjectAlternativeNameExtension; -import sun.security.x509.X509Key; public class TestCertificateAdd extends ClientTest { @@ -125,12 +122,6 @@ public class TestCertificateAdd extends ClientTest { }, res); } - @Test - public void testSPKAC() throws GeneralSecurityException, IOException { - testSPKAC(false); - testSPKAC(true); - } - @Test public void testIssue() throws IOException, GeneralSecurityException { HttpURLConnection huc = sendCertificateForm("description"); @@ -141,12 +132,12 @@ public class TestCertificateAdd extends ClientTest { byte[] cer = IOUtils.readURL(uc.getInputStream()); assertArrayEquals(cer, PEM.decode("CERTIFICATE", crt)); - uc = authenticate(new URL(huc.getHeaderField("Location") + ".cer?install&chain")); + uc = authenticate(new URL(huc.getHeaderField("Location") + ".cer?chain")); byte[] pkcs7 = IOUtils.readURL(uc.getInputStream()); PKCS7 p7 = new PKCS7(pkcs7); byte[] sub = verifyChain(p7.getCertificates()); assertArrayEquals(cer, sub); - assertEquals("application/x-x509-user-cert", uc.getHeaderField("Content-type")); + assertEquals("application/pkix-cert", uc.getHeaderField("Content-type")); uc = authenticate(new URL(huc.getHeaderField("Location"))); String gui = IOUtils.readURL(uc); @@ -312,32 +303,6 @@ public class TestCertificateAdd extends ClientTest { return uc; } - protected String testSPKAC(boolean correctChallenge) throws GeneralSecurityException, IOException { - HttpURLConnection uc = (HttpURLConnection) ncert.openConnection(); - uc.setRequestProperty("Cookie", cookie); - String s = IOUtils.readURL(uc); - - csrf = extractPattern(s, Pattern.compile("]*name='csrf' [^>]*value='([^']*)'>")); - String challenge = extractPattern(s, Pattern.compile("]*name=\"SPKAC\" [^>]*challenge=\"([^\"]*)\"/>")); - - SPKAC spk = new SPKAC((X509Key) kp.getPublic(), challenge + (correctChallenge ? "" : "b")); - Signature sign = Signature.getInstance("SHA512WithRSA"); - sign.initSign(kp.getPrivate()); - try { - String[] res = fillOutFormDirect("SPKAC=" + URLEncoder.encode(Base64.getEncoder().encodeToString(spk.getEncoded(sign)), "UTF-8")); - if ( !correctChallenge) { - fail("Should not succeed with wrong challenge."); - } - assertArrayEquals(new String[] { - "client", CertificateRequest.DEFAULT_CN, "", Digest.SHA512.toString() - }, res); - } catch (OnPageError e) { - String error = fetchStartErrorMessage(e.getMessage()); - assertTrue(error, error.startsWith("

Challenge mismatch")); - } - return csrf; - } - private PKCS10Attributes buildAtts(ObjectIdentifier[] ekuOIDs, GeneralNameInterface... SANs) throws IOException { CertificateExtensions attributeValue = new CertificateExtensions(); GeneralNames names = new GeneralNames();