B4J Question Webview & Certificate Lets encrypt

Discussion in 'B4J Questions' started by Siam, Mar 19, 2016.

  1. Siam

    Siam Active Member Licensed User


    i will open an SSL Page witch has a Let's encrypt Certificate but nothing happens

    if i load :

    webview1.LoadUrl("https://www.siam-net.de") or webview1.LoadUrl("https://smarthome.iokz.de")
    nothing happens.. no error... no page .. nothing

    if i load
    it works fine.

    is it possible that the webview can't handle the certificate from let's encrypt ?


  2. Erel

    Erel Administrator Staff Member Licensed User

    You can disable the SSL tests with this code:
    Sub AppStart (Form1 As Form, Args() As String)
       MainForm = Form1
    "1"'Load the layout file.
    Dim jo As JavaObject = Me
    End Sub

    #if JAVA
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.security.GeneralSecurityException;

    import javax.net.ssl.HttpsURLConnection;
    import javax.net.ssl.SSLContext;
    import javax.net.ssl.TrustManager;
    import javax.net.ssl.X509TrustManager;
    public static void disableSSLTest() {

         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 the all-trusting trust manager
         try {
           SSLContext sc = SSLContext.getInstance("SSL");
           sc.init(null, trustAllCerts, new java.security.SecureRandom());
         } catch (GeneralSecurityException e) {
         // Now you can access an https URL without having the certificate in the truststore
         try {
           URL url = new URL("https://hostname/index.html");
         } catch (MalformedURLException e) {
    #end if
    Based on this answer: http://stackoverflow.com/questions/...not-working-using-a-untrusted-ssl-certificate
    Siam likes this.
  3. Siam

    Siam Active Member Licensed User

    hi erel,

    thank you !! now it works


  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice