javassljavafxchromium-embeddedjxbrowser

jxbrowser - disable ssl/tls certificate check


I need to disable HTTP chertificate check in fxBrowser via JAVAfx, Now I'm calling it as

AnchorPane = new AnchorPane();
BrowserView _nodevW;

Browser _browser =  Engine.newInstance(
    EngineOptions.newBuilder(
        OFF_SCREEN
    ).addSwitch("--allow-running-insecure-content")
    .chromiumDir(
        "C:\\TMP\\JX"
    ).enableProprietaryFeature(
        ProprietaryFeature.H_264
    ).enableIncognito().build()
    
    _browser = engine.newBrowser();
    _nodevW = BrowserView.newInstance(_browser);
    _browser.navigation().loadUrl(url);
    
    
    anchorPane.getChildren().addAll(_nodevW);

It works perfectly for plain http and https with valid certificates, but fails for self-signed or certificate deemed invalid with ERR_CERT_AUTHORITY_INVALID

How do I tell the browser to ignore invalid certificates (I can't install the certificates on client machines, but I can ignore them)


Solution

  • You can ignore the invalid SSL certificates and continue loading an HTTPS web page using the following approach:

    Network network = engine.network();
    network.set(VerifyCertificateCallback.class, (params) -> 
            VerifyCertificateCallback.Response.valid());
    

    You can read more about this API in documentation.