This discussion is archived
8 Replies Latest reply: Oct 1, 2013 9:21 AM by user13425887 RSS

JavaFX WebView not loading a url with https

user13425887 Newbie
Currently Being Moderated
Hi

I am working on JavaFX webview. when I try to load an https url the webview is not created. webengine.load("https://........"); it gives an unexpected error.

I have found an solution in stackoverflow http://stackoverflow.com/questions/13356633/javafx-webview-not-loading-https-page.
Saying you need to have sunjce_provider.jar in JRE bundle. I have the jar in my JRE bundle but the webview is not creating.

Same url if i load in browser it gives certificate expired warring. When I click proceed it shows the page but in the javaFX webview the page is not loading.

Can any one give suggestion what might be the problem.

Thanks in advance
  • 1. Re: JavaFX WebView not loading a url with https
    jsmith Guru
    Currently Being Moderated
    Same url if i load in browser it gives certificate expired warring.
    This certificate expired status causes your issue.

    Strictly speaking, because the certificate is expired, the connection is untrustworthy and the Java networking layer does not let the user use the connection.

    The browser is also detecting the expired certificate, but instead of refusing the connection, it pops up a warning and allows the user to continue regardless if they wish. Replicating the browser behavior in Java by adding custom url handlers to the network layer and an interstitial page when an invalid connection is detected may be possible, but would likely prove difficult for you. Certainly, when I created a sample browser in JavaFX, I did not try to implement such a mechanism due to the potential difficulty and security implications of doing so.

    The best solution is for the server maintainer to upgrade the certificate on their service to a valid one. I understand that you may have little control over that process.

    If you google around, you may find solutions which allow you to disable certificate validity checking for java networking connections. These will likely allow WebView to connect to the target site, but, before enabling such a scheme, make sure you understand the security implications of doing so.
  • 2. Re: JavaFX WebView not loading a url with https
    user13425887 Newbie
    Currently Being Moderated
    Thank you for your response. I have figured some things but still having issue.

    The url that I was trying to load was has self signed certificated created using openssl. To try an example in apache webserver (WAMP) added an self signed certificate url (https://localhost).
    I add the certificate to cacerts in the JRE security folder using the using the keytool(C:\Program Files\Java\jdk1.7.0_11\jre\lib\security\cacerts) (keytool -import -keystore c:/"Program Files"/java/jdk1.7.0_11/jre/lib/security/cacerts -file c:/www.amicusac.der).

    I ran the application with webview localhost works fine but the https://localhost does load again in the webview.

    Here the certificate is new one and not expired & I have added it to the cacerts in JRE security folder but also its not loading. Is there anything I am doing wrong in added the self signed certificate to the JRE. Can you please let me know

    I am running the application in netbeans. The library & platform is C:\Program Files\Java\jdk1.7.0_1. I have updated the certifacte under this JRE it self.

    The links that I have used.
    WAMP for self signed certifiacte
    http://www.viduka.info/eblog/kebic/how-to-setup-https-ssl-on-wamp.html
    To added certificate to cacerts
    http://www.grim.se/guide/jre-cert

    Thanks in advance
  • 3. Re: JavaFX WebView not loading a url with https
    jsmith Guru
    Currently Being Moderated
    What is the point of running https with a self signed certificate on localhost? Especially if it is causing you difficulties? https is a transport layer protocol designed to protect information from man in the middle attacks as data transfers across a network. If everything is local to a single machine, it's useless as far as I know and you may as well just use plain http instead - in which case you don't need to solve any of these issues.
  • 4. Re: JavaFX WebView not loading a url with https
    user13425887 Newbie
    Currently Being Moderated
    I was trying to test what exactly is the issue. when I was trying to load URL which is not localhost its not loading, that's why I created the self signed certificate which expires in 365 days and added to apache server in localhost and testing it.

    But the issue is resolved when I added the certificate of the URL that I want to load to the JRE cacerts it loaded in the JavaFX webview and its working fine.

    Is there any program that if there is an new certificate from url we added it to cacerts in JRE security folder.

    Thank you for response and time.
  • 5. Re: JavaFX WebView not loading a url with https
    jsmith Guru
    Currently Being Moderated
    Is there any program that if there is an new certificate from url we added it to cacerts in JRE security folder.
    If you are going to add every certificate you encounter to the trust store, you may as well just disable certificate checking or use plain http instead.

    Just google for: "java disable certificate validation"
  • 6. Re: JavaFX WebView not loading a url with https
    user13425887 Newbie
    Currently Being Moderated

    Hi,

     

    I am working on Javafx Webiew in swing application.

    I have created an Webview and loading an URL but when we submit the form, the javascripts validation should be done but they are not done in the background.

    Generally if I load that URL in chrome browser and hit submit, it show error for required fields of the form. But its not working in the webview.

     

    I have tested by enabling the firebug, the java scripts get loaded but the validation is not done.

     

    Can you let me know is there anything that I need to enable to execute the scripts loaded from the URL to work in the webengine

     

    Can you give me suggestion what might be the problem.

  • 7. Re: JavaFX WebView not loading a url with https
    jsmith Guru
    Currently Being Moderated

    @user13425887 your new question is not related to the original question.  Create a new question.  In your new question include a sample app, sample URL and reproduction steps or you will be unable to get help.

  • 8. Re: JavaFX WebView not loading a url with https
    user13425887 Newbie
    Currently Being Moderated

    Hi jsmith

     

    I have created new question added more details about the issue. The HTML 5 attribute required is not working in javafx webview webengine.

     

    the link to the new thread.

    JavaFX Webengine not validating the form using javascripts loaded from the URL

     

    Thank you for your help in advance

    Abhilash

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points