java - JavaFX WebView not working using a untrusted SSL certificate -


i'm developing simple embedded browser using javafx:

final webview browser = new webview(); final webengine webengine = browser.getengine(); 

when use webengine load http website, works fine:

webengine.load("http://google.es"); 

despite this, if try load website untrusted certificate (my own ssl certificate), webengine not work , white screen in browser.

is there way (automatically) trust in ssl certificate?

finally, solved question. should add code before loading website:

// create trust manager not validate certificate chains trustmanager[] trustallcerts = new trustmanager[] {      new x509trustmanager() {              public java.security.cert.x509certificate[] getacceptedissuers() {              return null;         }          public void checkclienttrusted(              java.security.cert.x509certificate[] certs, string authtype) {             }          public void checkservertrusted(              java.security.cert.x509certificate[] certs, string authtype) {         }     }  };   // install all-trusting trust manager try {     sslcontext sc = sslcontext.getinstance("ssl");      sc.init(null, trustallcerts, new java.security.securerandom());      httpsurlconnection.setdefaultsslsocketfactory(sc.getsocketfactory()); } catch (generalsecurityexception e) { }  // can access https url without having certificate in truststore try {      url url = new url("https://hostname/index.html");  } catch (malformedurlexception e) { }  //now can load content:  webengine.load("https://example.com"); 

note: code fragment disable certificates validation, not trusts it.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -