Challenge mismatch"));
}
+ return csrf;
}
private PKCS10Attributes buildAtts(ObjectIdentifier[] ekuOIDs, GeneralNameInterface... SANs) throws IOException {
@@ -142,20 +313,24 @@ public class TestCertificateAdd extends ManagedTest {
private String[] fillOutForm(String pem) throws IOException {
HttpURLConnection uc = (HttpURLConnection) ncert.openConnection();
- uc.setRequestProperty("Cookie", session);
- String csrf = getCSRF(uc);
- return fillOutForm(csrf, pem);
+ uc.setRequestProperty("Cookie", cookie);
+ csrf = getCSRF(uc);
+ return fillOutFormDirect(pem);
}
- private String[] fillOutForm(String csrf, String pem) throws IOException {
+ private String[] fillOutFormDirect(String pem) throws IOException {
HttpURLConnection uc = (HttpURLConnection) ncert.openConnection();
- uc.setRequestProperty("Cookie", session);
+ uc.setRequestProperty("Cookie", cookie);
uc.setDoOutput(true);
- uc.getOutputStream().write(("csrf=" + URLEncoder.encode(csrf, "UTF-8") + "&" + pem).getBytes());
+ uc.getOutputStream().write(("csrf=" + URLEncoder.encode(csrf, "UTF-8") + "&" + pem).getBytes("UTF-8"));
uc.getOutputStream().flush();
+ return extractFormData(uc);
+ }
+
+ private String[] extractFormData(HttpURLConnection uc) throws IOException, Error {
String result = IOUtils.readURL(uc);
if (result.contains("
")) {
String s = fetchStartErrorMessage(result);
@@ -163,7 +338,7 @@ public class TestCertificateAdd extends ManagedTest {
}
String profileKey = extractPattern(result, Pattern.compile("