import java.security.GeneralSecurityException;
import java.security.KeyPair;
import java.security.Signature;
+import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
OutputStream out = huc.getOutputStream();
out.write(("csrf=" + URLEncoder.encode(csrf, "UTF-8")).getBytes("UTF-8"));
out.write(("&CN=CAcert+WoT+User&profile=client&SANs=" + URLEncoder.encode("email:" + email + "\n", "UTF-8")).getBytes("UTF-8"));
- out.write(("&hash_alg=SHA512&CCA=y").getBytes("UTF-8"));
+ out.write(("&hash_alg=SHA512&tos_agree=y").getBytes("UTF-8"));
URLConnection uc = authenticate(new URL(huc.getHeaderField("Location") + ".crt"));
String crt = IOUtils.readURL(new InputStreamReader(uc.getInputStream(), "UTF-8"));
byte[] cer = IOUtils.readURL(uc.getInputStream());
assertArrayEquals(cer, PEM.decode("CERTIFICATE", crt));
- uc = authenticate(new URL(huc.getHeaderField("Location") + ".cer?install"));
+ uc = authenticate(new URL(huc.getHeaderField("Location") + ".cer?install&chain"));
byte[] pkcs7 = IOUtils.readURL(uc.getInputStream());
PKCS7 p7 = new PKCS7(pkcs7);
byte[] sub = verifyChain(p7.getCertificates());
uc = authenticate(new URL(huc.getHeaderField("Location")));
String gui = IOUtils.readURL(uc);
+ Pattern p = Pattern.compile("-----BEGIN CERTIFICATE-----[^-]+-----END CERTIFICATE-----");
+ Matcher m = p.matcher(gui);
+ assertTrue(m.find());
+ byte[] cert = PEM.decode("CERTIFICATE", m.group(0));
+ Certificate c = CertificateFactory.getInstance("X509").generateCertificate(new ByteArrayInputStream(cert));
+ gui = c.toString();
assertThat(gui, containsString("clientAuth"));
assertThat(gui, containsString("CN=CAcert WoT User"));
assertThat(gui, containsString("SHA512withRSA"));
}
}
}
+ assertNotNull(current);
return current.getEncoded();
}
}
Date start = new Date(now);
Date end = new Date(now + MS_PER_DAY * 10);
- X509Certificate res = createCertWithValidity("&validFrom=" + sdf.format(start) + "&validity=" + sdf.format(end));
- assertNotNull(res);
+ String validity = "&validFrom=" + sdf.format(start) + "&validity=" + sdf.format(end);
+ X509Certificate res = createCertWithValidity(validity);
+ assertNotNull(validity, res);
assertEquals(start, res.getNotBefore());
assertEquals(end, res.getNotAfter());
}
OutputStream out = huc.getOutputStream();
out.write(("csrf=" + URLEncoder.encode(csrf, "UTF-8")).getBytes("UTF-8"));
out.write(("&profile=client&CN=" + CertificateRequest.DEFAULT_CN + "&SANs=" + URLEncoder.encode("email:" + email + "\n", "UTF-8")).getBytes("UTF-8"));
- out.write(("&hash_alg=SHA512&CCA=y&").getBytes("UTF-8"));
+ out.write(("&hash_alg=SHA512&tos_agree=y&").getBytes("UTF-8"));
out.write(validity.getBytes("UTF-8"));
String certurl = huc.getHeaderField("Location");