java - HTTPS Post request (not) using certificate/hash print? -


i admit there possibility not informed subject, i've done loads of reading , still can't answer question.

from have learnt, make communication secure https need using sort of public key (reminds me of pgp-encryption).

my goal make secured post request java application (which i, in moment starts working, rewrite android app, if matters) php application accessible via https address.

naturally did google research on topic , got lot of results how make ssl connection. non of results used sort of certificate/hash prints. use httpsurlconnection instead of httpurlconnection, else identical.

right now, copy paste of found here this:

string httpsurl = "https://xx.yyyy.zzz/requesthandler.php?getparam1=value1&getparam2=value2";      string query = "email=" + urlencoder.encode("abc@xyz.com", "utf-8");     query+="&";     query+="password="+urlencoder.encode("tramtarie","utf-8");      url myurl = new url(httpsurl);     httpsurlconnection con = (httpsurlconnection) myurl.openconnection();     con.setrequestmethod("post");      con.setrequestproperty("content-length",string.valueof(query.length()));     con.setrequestproperty("content-type","application/x-www-form-urlencoded");     con.setrequestproperty("user-agent","mozilla/4.0 (compatible; msie 5.0;windows98;digext)");     con.setdooutput(true);     con.setdoinput(true);      dataoutputstream output = new dataoutputstream(con.getoutputstream());       output.writebytes(query);      output.close();       datainputstream input = new datainputstream(con.getinputstream());       for(     int c = input.read();     c!=-1;c=input.read())             system.out.print((char)c);     input.close();      system.out.println("resp code:"+con.getresponsecode());     system.out.println("resp message:"+con.getresponsemessage()); 

which sadly not work , ends exception:

exception in thread "main" javax.net.ssl.sslhandshakeexception: java.security.cert.certificateexception: no subject alternative dns name matching app.elessy.cz found 

this means checks certificate , finds out certificate using not match domain name registered (it webhosting certificate, registered webhosting domain, not domain own, reason using https secure data internal purposes, not want site visited users outside, certificate should ok).

there 2 things don't code , everything.

  1. no code have been able find use md5/sha-1 (supposedly public keys message encryption?) prints or certificate, somehow automatically connect https website , should work. doesn't work me though.
  2. do need md5/sha-1 prints provided me? or @ least, in given context prints mean?

edit:

following given answer , duplicate mark, managed working - in meaning can communicate application behind https. didnt have use sort of md5/sha1 print. how know safe? protocol on own? communication secured either way, when use built-in java classes connect app behind https?

i not seek precise technical explanation, more assurance yes - communication safe though not use (knowingly) certificate/servers public key encrypt messages. ssl connection me.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -