String[] res = fillOutForm("CSR=" + URLEncoder.encode(pem, "UTF-8"));
assertArrayEquals(new String[] {
- "mail", "a b", "dns:a." + uniq + ".tld\ndns:b." + uniq + ".tld\nemail:" + email + "\n", Digest.SHA384.toString()
+ "mail", "a b", "email:" + email + "\ndns:a." + uniq + ".tld\ndns:b." + uniq + ".tld\n", Digest.SHA384.toString()
}, res);
}
huc.setRequestProperty("Cookie", cookie);
huc.setDoOutput(true);
OutputStream out = huc.getOutputStream();
- out.write(("csrf=" + URLEncoder.encode(csrf, "UTF-8")).getBytes());
- out.write(("&profile=client&CN=a+b&SANs=" + URLEncoder.encode("email:" + email + "\n", "UTF-8")).getBytes());
- out.write(("&hash_alg=SHA512&CCA=y").getBytes());
+ out.write(("csrf=" + URLEncoder.encode(csrf, "UTF-8")).getBytes("UTF-8"));
+ out.write(("&profile=client&CN=a+b&SANs=" + URLEncoder.encode("email:" + email + "\n", "UTF-8")).getBytes("UTF-8"));
+ out.write(("&hash_alg=SHA512&CCA=y").getBytes("UTF-8"));
URLConnection uc = authenticate(new URL(huc.getHeaderField("Location") + ".crt"));
String crt = IOUtils.readURL(new InputStreamReader(uc.getInputStream(), "UTF-8"));
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);
assertEquals(start, res.getNotBefore());
assertEquals(end, res.getNotAfter());
}
huc.setRequestProperty("Cookie", cookie);
huc.setDoOutput(true);
OutputStream out = huc.getOutputStream();
- out.write(("csrf=" + URLEncoder.encode(csrf, "UTF-8")).getBytes());
- out.write(("&profile=client&CN=a+b&SANs=" + URLEncoder.encode("email:" + email + "\n", "UTF-8")).getBytes());
- out.write(("&hash_alg=SHA512&CCA=y&").getBytes());
- out.write(validity.getBytes());
+ out.write(("csrf=" + URLEncoder.encode(csrf, "UTF-8")).getBytes("UTF-8"));
+ out.write(("&profile=client&CN=a+b&SANs=" + URLEncoder.encode("email:" + email + "\n", "UTF-8")).getBytes("UTF-8"));
+ out.write(("&hash_alg=SHA512&CCA=y&").getBytes("UTF-8"));
+ out.write(validity.getBytes("UTF-8"));
String certurl = huc.getHeaderField("Location");
if (certurl == null) {
String crt = IOUtils.readURL(new InputStreamReader(uc.getInputStream(), "UTF-8"));
CertificateFactory cf = CertificateFactory.getInstance("X.509");
- X509Certificate parsed = (X509Certificate) cf.generateCertificate(new ByteArrayInputStream(crt.getBytes()));
+ X509Certificate parsed = (X509Certificate) cf.generateCertificate(new ByteArrayInputStream(crt.getBytes("UTF-8")));
return parsed;
}
HttpURLConnection uc = (HttpURLConnection) ncert.openConnection();
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);