Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #28666 > unrolled thread

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

Started byrjmpsmith@gmail.com
First post2014-06-05 13:37 -0700
Last post2014-06-05 17:42 -0400
Articles 5 — 4 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  JAXP throws "javax.net.ssl.SSLHandshakeException" accessing local file??? rjmpsmith@gmail.com - 2014-06-05 13:37 -0700
    Re: JAXP throws "javax.net.ssl.SSLHandshakeException" accessing local file??? Robert Smith <rjmpsmith@gmail.com> - 2014-06-05 14:34 -0700
    Re: JAXP throws "javax.net.ssl.SSLHandshakeException" accessing local file??? Arne Vajhøj <arne@vajhoej.dk> - 2014-06-05 17:38 -0400
      Re: JAXP throws "javax.net.ssl.SSLHandshakeException" accessing local file??? Robert Smith <rjmpsmith@gmail.com> - 2014-06-05 14:58 -0700
    Re: JAXP throws "javax.net.ssl.SSLHandshakeException" accessing local file??? Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-06-05 17:42 -0400

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

Fromrjmpsmith@gmail.com
Date2014-06-05 13:37 -0700
SubjectJAXP throws "javax.net.ssl.SSLHandshakeException" accessing local file???
Message-ID<55d4756d-d28d-4e11-9196-b751f3f92fda@googlegroups.com>
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?

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.AbstractDelegateHttpsURLConnection.connect(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 to find 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

[toc] | [next] | [standalone]


#28667

FromRobert Smith <rjmpsmith@gmail.com>
Date2014-06-05 14:34 -0700
Message-ID<5810b193-23f8-4ccc-8123-7f59c55d6cd6@googlegroups.com>
In reply to#28666
By the way, I am using Java 7, and I'm beginning to think that has something to do with it...

[toc] | [prev] | [next] | [standalone]


#28668

FromArne Vajhøj <arne@vajhoej.dk>
Date2014-06-05 17:38 -0400
Message-ID<5390e348$0$295$14726298@news.sunsite.dk>
In reply to#28666
On 6/5/2014 4:37 PM, rjmpsmith@gmail.com 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.AbstractDelegateHttpsURLConnection.connect(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

[toc] | [prev] | [next] | [standalone]


#28670

FromRobert Smith <rjmpsmith@gmail.com>
Date2014-06-05 14:58 -0700
Message-ID<d6b16c31-aba0-46eb-a89c-ac9bc0c36142@googlegroups.com>
In reply to#28668
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

[toc] | [prev] | [next] | [standalone]


#28669

FromEric Sosman <esosman@comcast-dot-net.invalid>
Date2014-06-05 17:42 -0400
Message-ID<lmqo7u$3h7$1@dont-email.me>
In reply to#28666
On 6/5/2014 4:37 PM, rjmpsmith@gmail.com 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
esosman@comcast-dot-net.invalid

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web