Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String url = "http://192.168.1.135:9999/register_with_certificate";
- String urlParameters = "cert="+cert_x509.toString();
- URL obj = new URL(url);
- HttpURLConnection con = (HttpURLConnection) obj.openConnection();
- //add reuqest header
- con.setRequestMethod("POST");
- con.setRequestProperty("Accept-Language"
- , "en-US,en;q=0.5");
- // Send post request
- con.setDoOutput(true);
- con.setFollowRedirects(true);
- DataOutputStream wr = new DataOutputStream(con.getOutputStream());
- wr.writeBytes(urlParameters);
- wr.flush();
- wr.close();
- con.setFollowRedirects(true);
- String c= params.get("cert");
- try {
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- ByteArrayInputStream bis = new ByteArrayInputStream(c.getBytes());
- Certificate cer = cf.generateCertificate(bis);
- } catch (CertificateException e1) {
- // TODO Auto-generated catch block
- System.out.println("catch-------------------");
- }
- java.security.cert.CertificateException:Could not parse certificate: java.io.IOException: Empty input
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement