1

I am using JSoup to fetch websites.

I do the fetch with this line:

 Document doc = Jsoup.connect(urlString).get();

The code works fine the first time it is run each instance of my program. If I then do another fetch, I eventually get the following error:

        javax.net.ssl.SSLHandshakeException: No subject alternative DNS name matching <domain> found.
    at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:128)
    at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:321)
    at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:264)
    at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:259)
    at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.checkServerCerts(CertificateMessage.java:1329)
    at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.onConsumeCertificate(CertificateMessage.java:1204)
    at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.consume(CertificateMessage.java:1151)
    at java.base/sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:392)
    at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:444)
    at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:421)
    at java.base/sun.security.ssl.TransportContext.dispatch(TransportContext.java:178)
    at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:164)
    at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1152)
    at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1063)
    at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:402)
    at java.base/sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:567)
    at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
    at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:163)
    at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:730)
    at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:706)
    at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:299)
    at org.jsoup.helper.HttpConnection.get(HttpConnection.java:288)
    at net.joshuad.novaprice.scrapers.Scraper.getSellPrice(Scraper.java:149)
    at net.joshuad.novaprice.mtg.Pricer.getSellPrices(Pricer.java:20)
    at net.joshuad.novaprice.MainPanel.lambda$6(MainPanel.java:271)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.security.cert.CertificateException: No subject alternative DNS name matching starcitygames.com found.
    at java.base/sun.security.util.HostnameChecker.matchDNS(HostnameChecker.java:207)
    at java.base/sun.security.util.HostnameChecker.match(HostnameChecker.java:98)
    at java.base/sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:459)
    at java.base/sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:434)
    at java.base/sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:233)
    at java.base/sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:129)
    at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.checkServerCerts(CertificateMessage.java:1313)
    ... 21 more

Sometimes I can run the fetch only once. Sometimes I can run it three or four times. But eventually it fails with the above error. Once it fails, it always fails until the JVM and my program are restarted. If I restart the JVM and program, it then works again.

I have tried introducing time delays to see if the issue is requests made too quickly, but that doesn't seem to change anything. I'm able to make 1-4 requests successfully, then things go sour until I restart the program. It doesn't matter how much time delay there is between requests. Once it has failed once in this way, it will continue to fail until I restart the program.

My program is not keeping any cached information. All I do is fetch the content at the URL, read it and process it, then display it to the user. Each new fetch is (as far as my program is concerned) an independent transaction.

My program is pretty simple in format. It's basically:

 //Build the UI
 //Wait for User Search Input
 //Figure out the URL for the user's request
 Document doc = Jsoup.connect(urlString).get();
 //Process the data, display it to the user
 //Repeat until window closed. 

Any thoughts on how I can troubleshoot this one?

I am running this on Oracle Java JDK 11.0.1.

Grumblesaurus
  • 3,021
  • 3
  • 31
  • 61

1 Answers1

1

I was able to fix this problem by upgrading from Java 11 SDK to Java 13 SDK.

I saw recommendations to try adding -Dcom.sun.jndi.ldap.object.disableEndpointIdentification=true to the jvm arguments, but that didn't work for me.

Grumblesaurus
  • 3,021
  • 3
  • 31
  • 61