Skip to content

ALPN problem: IIS aborts the TLS handshake for HTTP 1.0 requests #12259

@mkauf

Description

@mkauf

I did this

Connect to a Microsoft IIS 10 server with HTTP 1.0:

$ curl -v --http1.0 https://my-iis-server/
* Host my-iis-server:443 was resolved.
* IPv6: (none)
* IPv4: 172.18.6.91
*   Trying 172.18.6.91:443...
* Connected to my-iis-server (172.18.6.91) port 443
* ALPN: curl offers http/1.0
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
*  CAfile: /etc/ssl/certs/ca-certificates.crt
*  CApath: /etc/ssl/certs
* Recv failure: Connection reset by peer
* OpenSSL SSL_connect: Connection reset by peer in connection to my-iis-server:443 
* Closing connection
curl: (35) Recv failure: Connection reset by peer

IIS aborts the TLS handshake with a TCP reset (RST) after the "client hello" message.

This is a regression, it works with curl 7.87.0 and earlier.

The root cause of the problem is the ALPN protocol that curl sends to the server. curl 7.88.0 has started to send "http/1.0" (commit df856cb, discussion #10183). Earlier curl versions use the ALPN protocol "http/1.1", even for HTTP 1.0 requests.

My guess is that the IIS server does not know the ALPN protocol "http/1.0". The original ALPN specification does not contain "http/1.0", but it contains "http/1.1".

Side note: Firefox also uses the ALPN protocol "http/1.1" even if the setting "network.http.version" is set to "1.0".

This hack fixes the problem:

diff --git a/lib/vtls/vtls_int.h b/lib/vtls/vtls_int.h
index 2e65e6303..a7d76fcc9 100644
--- a/lib/vtls/vtls_int.h
+++ b/lib/vtls/vtls_int.h
@@ -33,7 +33,7 @@
 #define ALPN_HTTP_1_1_LENGTH 8
 #define ALPN_HTTP_1_1 "http/1.1"
 #define ALPN_HTTP_1_0_LENGTH 8
-#define ALPN_HTTP_1_0 "http/1.0"
+#define ALPN_HTTP_1_0 "http/1.1"
 #define ALPN_H2_LENGTH 2
 #define ALPN_H2 "h2"
 #define ALPN_H3_LENGTH 2

Workaround: Use the parameter --no-alpn.

I expected the following

Successful transfer

curl/libcurl version

curl 8.5.0-DEV (x86_64-pc-linux-gnu) libcurl/8.5.0-DEV OpenSSL/3.0.9 nghttp2/1.52.0
Release-Date: [unreleased]
Protocols: dict file ftp ftps gopher gophers http https imap imaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS HSTS HTTP2 HTTPS-proxy IPv6 Largefile NTLM SSL threadsafe TLS-SRP UnixSockets

operating system

Fedora Linux 38

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions