JAXP throws "javax.net.ssl.SSLHandshakeException" accessing local file???

Discussion in 'Java' started by rjmpsmith@gmail.com, Jun 5, 2014.

  1. Guest

    Hi all,

    I'm trying to use JAXP and DOM to parse an XML file on the local disk. However, when I try, I am getting a "javax.net.ssl.SSLHandshakeException". Thisis a local file. I don't understand why anything related to SSL is going on. I've tried this on Windows and Linux. Same result.

    Any ideas?

    Cheers,

    Robert

    -----------------------------------

    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();

    File xmlFile = new File("/home/security/test.xml");

    Document document = builder.parse(xmlFile);
    ^^^^^^^^^^^^^^^^^^^^^^

    ------------------------------------

    Exception in thread "main" javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
    at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1884)
    at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:276)
    at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:270)
    at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1341)
    at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:153)
    at sun.security.ssl.Handshaker.processLoop(Handshaker.java:868)
    at sun.security.ssl.Handshaker.process_record(Handshaker.java:804)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1016)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1323)
    at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:563)
    at sun.net.www.protocol.https.AbstractDelegate...t(AbstractDelegateHttpsURLConnection.java:185)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1300)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
    at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
    at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source)
    at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unknown Source)
    at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:205)
    at com.intel.spd.bta.ParseTestsuiteLog.main(ParseTestsuiteLog.java:34)
    Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable tofind valid certification path to requested target
    at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:385)
    at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:230)
    at sun.security.validator.Validator.validate(Validator.java:260)
    at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:326)
    at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl..java:231)
    at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:126)
    at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1323)
    ... 24 more
    Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:196)
    at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:268)
    at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:380)
    ... 30 more
    , Jun 5, 2014
    #1
    1. Advertising

  2. Robert Smith Guest

    By the way, I am using Java 7, and I'm beginning to think that has something to do with it...
    Robert Smith, Jun 5, 2014
    #2
    1. Advertising

  3. Arne Vajhøj Guest

    Re: JAXP throws "javax.net.ssl.SSLHandshakeException" accessing localfile???

    On 6/5/2014 4:37 PM, wrote:
    > I'm trying to use JAXP and DOM to parse an XML file on the local disk. However, when I try, I am getting a "javax.net.ssl.SSLHandshakeException". This is a local file. I don't understand why anything related to SSL is going on. I've tried this on Windows and Linux. Same result.
    >
    > Any ideas?


    > DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    > DocumentBuilder builder = factory.newDocumentBuilder();
    >
    > File xmlFile = new File("/home/security/test.xml");
    >
    > Document document = builder.parse(xmlFile);
    > ^^^^^^^^^^^^^^^^^^^^^^


    > Exception in thread "main" javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    > at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
    > at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1884)
    > at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:276)
    > at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:270)
    > at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1341)
    > at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:153)
    > at sun.security.ssl.Handshaker.processLoop(Handshaker.java:868)
    > at sun.security.ssl.Handshaker.process_record(Handshaker.java:804)
    > at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1016)
    > at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)
    > at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339)
    > at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1323)
    > at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:563)
    > at sun.net.www.protocol.https.AbstractDelegate...t(AbstractDelegateHttpsURLConnection.java:185)
    > at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1300)
    > at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
    > at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
    > at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source)
    > at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unknown Source)
    > at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(Unknown Source)
    > at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown Source)
    > at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    > at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    > at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    > at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    > at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
    > at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    > at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:205)
    > at com.intel.spd.bta.ParseTestsuiteLog.main(ParseTestsuiteLog.java:34)


    Does the XML file refer to a DTD that is to be fetched via HTTPS?

    Arne
    Arne Vajhøj, Jun 5, 2014
    #3
  4. Eric Sosman Guest

    Re: JAXP throws "javax.net.ssl.SSLHandshakeException" accessing localfile???

    On 6/5/2014 4:37 PM, wrote:
    > Hi all,
    >
    > I'm trying to use JAXP and DOM to parse an XML file on the local disk. However, when I try, I am getting a "javax.net.ssl.SSLHandshakeException". This is a local file. I don't understand why anything related to SSL is going on. I've tried this on Windows and Linux. Same result.
    >
    > Any ideas?


    Not really an "idea," just a "guess:" Does your XML file use entity
    references (or a DTD) that needs to be looked up on the net?

    --
    Eric Sosman
    d
    Eric Sosman, Jun 5, 2014
    #4
  5. Robert Smith Guest

    Ach!!!! Yes, it is using a dtd via https. Okay that explains it. Sanity restored.

    As it turns out:

    factory.setValidating(false);

    does not prevent using the DTD, but:
    factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);

    does.

    Many thanks!!!!!!


    >
    >
    > Does the XML file refer to a DTD that is to be fetched via HTTPS?
    >
    >
    >
    > Arne
    Robert Smith, Jun 5, 2014
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. someone
    Replies:
    2
    Views:
    4,131
    someone
    Feb 28, 2004
  2. Blue Gecko
    Replies:
    1
    Views:
    436
    Blue Gecko
    Oct 3, 2005
  3. Lyndon
    Replies:
    1
    Views:
    510
    Leonard Blaisdell
    Jul 25, 2005
  4. bugbear
    Replies:
    0
    Views:
    1,001
    bugbear
    Aug 28, 2003
  5. germ
    Replies:
    1
    Views:
    784
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    Jul 6, 2007
Loading...

Share This Page