Project

Profile

Help

Any idea why .NET version of Saxon gives "FOUT1170: Failed to read input file: Received fatal alert: protocol_version"?

Added by Martin Honnen almost 7 years ago

When I used Saxon-HE 9.8.0.7N from the command line with options -t -it -xsl:test201801310101.xsl to execute the code

<pre><code class="xml">
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
	xmlns:math="http://www.w3.org/2005/xpath-functions/math"
	xmlns:map="http://www.w3.org/2005/xpath-functions/map"
	xmlns:array="http://www.w3.org/2005/xpath-functions/array"
	exclude-result-prefixes="xs math map array"
	version="3.0">
	
	<xsl:param name="json-url" as="xs:string">https://martin-honnen.github.io/xslt/2018/test2018013101.json</xsl:param>
	
	<xsl:output indent="yes"/>
	
	<xsl:template match="/" name="xsl:initial-template">
		<xsl:sequence select="json-to-xml(unparsed-text($json-url))"/>
	</xsl:template>
	
</xsl:stylesheet>
</code></pre>

Saxon does not manage to access that file and outputs

Error at char 26 in xsl:sequence/@select on line 15 column 65 of test201801310101.xsl: FOUT1170: Failed to read input file: Received fatal alert: protocol_version Failed to read input file

It is .NET 4.0.30319.42000 on Microsoft Windows NT 6.2.9200.0.

The same program run with the Java version runs fine.

I am currently at loss why that happens, is HTTPS somehow the culprit?


Replies (9)

Please register to reply

RE: Any idea why .NET version of Saxon gives "FOUT1170: Failed to read input file: Received fatal alert: protocol_version"? - Added by Michael Kay almost 7 years ago

It does look as if it's some kind of HTTPS / SSL / TLS issue.

See for example https://stackoverflow.com/questions/16541627/javax-net-ssl-sslexception-received-fatal-alert-protocol-version

One of the answers there suggests setting

System.setProperty("https.protocols", "TLSv1");

Saxon is doing (in StandardUnparsedTextResolver):

            URLConnection connection = absoluteURL.openConnection();
            connection.setRequestProperty("Accept-Encoding", "gzip");
            try {
                connection.connect();
            } catch (IOException ioe) {
                XPathException xpe = new XPathException("Failed to read input file", ioe);
                xpe.setErrorCode("FOUT1170");
                throw xpe;
            }

Unlike some of the other resolvers I don't think there's a different version for .NET, and we don't explicitly invoke .NET methods (that is, we rely on IKVM to do the necessary). You could try setting your own UnparsedTextResolver either to get more diagnostics or to change the properties on the URLConnection.

RE: Any idea why .NET version of Saxon gives "FOUT1170: Failed to read input file: Received fatal alert: protocol_version"? - Added by Martin Honnen almost 7 years ago

So https://stackoverflow.com/a/47717547/252228 and https://blogs.oracle.com/java-platform-group/diagnosing-tls,-ssl,-and-https suggest the Java 7 JRE uses the outdated TLSv1 as its default. I understand Saxon 9.8 uses IKVM 7 and that uses Java 7 so I tried to set @java.lang.System.setProperty("https.protocols", "TLSv1.2");@ in .NET code (had to add a reference to IKVM.OpenJDK.Core) and then Saxon 9.8 HE can use @unparsed-text@ on a GitHub HTTPS URL like https://martin-honnen.github.io/xslt/2018/test2018013101.json.

However, that doesn't help when running Transform.exe from the command line. Or is there any way to set Java system properties when running Saxon .NET 9.8 command line tools like Transform.exe?

RE: Any idea why .NET version of Saxon gives "FOUT1170: Failed to read input file: Received fatal alert: protocol_version"? - Added by T Hata almost 7 years ago

A possible workaround would be placing this alongside Transform.exe

<pre><code class="xml">
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
	<appSettings>
		<add key="ikvm:https.protocols" value="TLSv1,TLSv1.1,TLSv1.2" />
	</appSettings>
</configuration>
</code></pre>

RE: Any idea why .NET version of Saxon gives "FOUT1170: Failed to read input file: Received fatal alert: protocol_version"? - Added by Martin Honnen almost 7 years ago

When I add @@ to the @web.config@ of an ASP.NET MVC app using Saxon 9.8 .NET that indeed fixes the problem, also when I use my own console application and add it the @App.config@. So thanks for that hint, it seems easier than inserting calls to Java's @System.setProperty@ into the application code.

However, what does your suggestion "placing this alongside Transform.exe" refer to, to put an @app.config@ into the @bin@ directory where @transform.exe@ sits? I have tried that now, it doesn't seem to pick up the setting.

RE: Any idea why .NET version of Saxon gives "FOUT1170: Failed to read input file: Received fatal alert: protocol_version"? - Added by T Hata almost 7 years ago

to put an @app.config@ into the @bin@ directory where @transform.exe@ sits?

The directory is there, but the file name should be @Transform.exe.config@ which worked on my end.

RE: Any idea why .NET version of Saxon gives "FOUT1170: Failed to read input file: Received fatal alert: protocol_version"? - Added by Martin Honnen almost 7 years ago

Ah, thanks a lot, that indeed works fine.

Nevertheless I wonder whether Saxonica could patch Saxon .NET to include that setting by default.

RE: Any idea why .NET version of Saxon gives "FOUT1170: Failed to read input file: Received fatal alert: protocol_version"? - Added by Michael Kay almost 7 years ago

Thanks, T. Hata, for this solution.

Have to say I hate setting Java system properties because the setting is VM-wide and can therefore upset other components of the application. Sadly problems like this are going to gradually accumulate now that IKVM is no longer maintained. I wonder if there's an equivalent property we can set at the URLConnection level?

RE: Any idea why .NET version of Saxon gives "FOUT1170: Failed to read input file: Received fatal alert: protocol_version"? - Added by Martin Honnen over 4 years ago

Does anyone know why part of the code snippets in previous sections of this topic are empty? I revisited the issue in the hope to allow me to find the settings for .NET/IKVM and I am sure they were contained earlier in this topic, now it seems some code snippets have been reduced to empty blocks. Has plan.io somehow changed their backend to handle code snippets differently and that way old content has been deleted?

RE: Any idea why .NET version of Saxon gives "FOUT1170: Failed to read input file: Received fatal alert: protocol_version"? - Added by Michael Kay over 4 years ago

We converted the whole database a while back from the proprietary Redmine format to Markdown, I guess things got lost in that process.

The presence of inline code between @-signs rather than backticks suggests that this post for some reason didn't get converted properly. I haven't seen the problem anywhere else.

    (1-9/9)

    Please register to reply