Skip to content

7.87.0 regression: --haproxy-protocol fails with SSL_ERROR_SYSCALL #10165

Closed

Description

@Sergio-IME

It works with 7.86.0
Happens with dafdb20 from #9855 (89ee5cf right before, is working)
The server is apache 2.4.54

I did this...

curl -vvv --haproxy-protocol -k https://127.0.0.1/

...and got this

*   Trying 127.0.0.1:443...
* Connected to 127.0.0.1 (127.0.0.1) port 443 (#0)
* ALPN: offers h2
* ALPN: offers http/1.1
* [CONN-0-0][CF-SSL] TLSv1.0 (OUT), TLS header, Certificate Status (22):
* [CONN-0-0][CF-SSL] TLSv1.3 (OUT), TLS handshake, Client hello (1):
* OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to 127.0.0.1:443 
* Closing connection 0
curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to 127.0.0.1:443

I expected the following

*   Trying 127.0.0.1:443...
* Connected to 127.0.0.1 (127.0.0.1) port 443 (#0)
> PROXY TCP4 127.0.0.1 127.0.0.1 59730 443
* ALPN: offers h2
* ALPN: offers http/1.1
* TLSv1.0 (OUT), TLS header, Certificate Status (22):
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS header, Certificate Status (22):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS header, Finished (20):
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.2 (OUT), TLS header, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS header, Supplemental data (23):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN: server accepted http/1.1
* Server certificate:
*  subject: CN=front
*  start date: Dec 26 16:32:35 2022 GMT
*  expire date: Dec 23 16:32:35 2032 GMT
*  issuer: CN=front
*  SSL certificate verify result: self-signed certificate (18), continuing anyway.
* TLSv1.2 (OUT), TLS header, Supplemental data (23):
> GET / HTTP/1.1
> Host: 127.0.0.1
> User-Agent: curl/7.86.0
> Accept: */*
> 
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* old SSL session ID is stale, removing
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Date: Mon, 26 Dec 2022 17:02:06 GMT
< Server: Apache
< Vary: Accept-Encoding
< X-Content-Type-Options: nosniff
< X-Frame-Options: sameorigin
< Content-Length: xxx
< Content-Type: text/html; charset=UTF-8
< 
Hello, World
* Connection #0 to host 127.0.0.1 left intact

curl/libcurl version

curl 7.87.0 (x86_64-pc-linux-gnu) libcurl/7.87.0 OpenSSL/3.0.7 zlib/1.2.13 brotli/1.0.9 zstd/1.5.2 libidn2/2.3.4 libpsl/0.21.1 (+libidn2/2.3.4) libssh2/1.10.0 nghttp2/1.51.0
Release-Date: 2022-12-21
Protocols: dict file ftp ftps gopher gophers http https imap imaps mqtt pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL threadsafe TLS-SRP UnixSockets zstd

operating system

Linux archbtw 6.1.1-zen1-1-zen #1 ZEN SMP PREEMPT_DYNAMIC Wed, 21 Dec 2022 22:27:59 +0000 x86_64 GNU/Linux

Activity

  1. bagder commented on Dec 27, 2022

    @bagder
    Member

    Does it make a difference if you ask for --http1.1 ?

  2. Sergio-IME commented on Dec 27, 2022

    @Sergio-IME
    Author

    nope

    $ curl -vvv --haproxy-protocol --http1.1 -k https://127.0.0.1/
    *   Trying 127.0.0.1:443...
    * Connected to 127.0.0.1 (127.0.0.1) port 443 (#0)
    * ALPN: offers http/1.1
    * [CONN-0-0][CF-SSL] TLSv1.0 (OUT), TLS header, Certificate Status (22):
    * [CONN-0-0][CF-SSL] TLSv1.3 (OUT), TLS handshake, Client hello (1):
    * OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to 127.0.0.1:443
    * Closing connection 0
    curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to 127.0.0.1:443
  3. self-assigned this
    on Dec 27, 2022
  4. icing commented on Dec 27, 2022

    @icing
    Contributor

    @Sergio-IME please have a look at #10167. The order in which haproxy protocol information and TLS handshake is being sent by 7.87.0 is wrong. This PR should address that.

  5. Sergio-IME commented on Dec 27, 2022

    @Sergio-IME
    Author

    @icing seems good 👍

    $ ./src/curl -V
    curl 7.87.1-DEV (x86_64-pc-linux-gnu) libcurl/7.87.1-DEV OpenSSL/3.0.7 zlib/1.2.13 brotli/1.0.9 zstd/1.5.2 libidn2/2.3.4 libpsl/0.21.1 (+libidn2/2.3.4) nghttp2/1.51.0 librtmp/2.3
    Release-Date: [unreleased]
    Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp
    Features: alt-svc AsynchDNS brotli HSTS HTTP2 HTTPS-proxy IDN IPv6 Largefile libz NTLM NTLM_WB PSL SSL threadsafe TLS-SRP UnixSockets zstd
    
    $ ./src/curl  -vvvk --haproxy-protocol https://127.0.0.1/
    *   Trying 127.0.0.1:443...
    * Connected to 127.0.0.1 (127.0.0.1) port 443 (#0)
    > PROXY TCP4 127.0.0.1 127.0.0.1 53966 443
    * ALPN: offers h2
    * ALPN: offers http/1.1
    * [CONN-0-0][CF-SSL] TLSv1.0 (OUT), TLS header, Certificate Status (22):
    * [CONN-0-0][CF-SSL] TLSv1.3 (OUT), TLS handshake, Client hello (1):
    * [CONN-0-0][CF-SSL] TLSv1.2 (IN), TLS header, Certificate Status (22):
    * [CONN-0-0][CF-SSL] TLSv1.3 (IN), TLS handshake, Server hello (2):
    * [CONN-0-0][CF-SSL] TLSv1.2 (IN), TLS header, Finished (20):
    * [CONN-0-0][CF-SSL] TLSv1.2 (IN), TLS header, Supplemental data (23):
    * [CONN-0-0][CF-SSL] TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
    * [CONN-0-0][CF-SSL] TLSv1.2 (IN), TLS header, Supplemental data (23):
    * [CONN-0-0][CF-SSL] TLSv1.3 (IN), TLS handshake, Certificate (11):
    * [CONN-0-0][CF-SSL] TLSv1.2 (IN), TLS header, Supplemental data (23):
    * [CONN-0-0][CF-SSL] TLSv1.3 (IN), TLS handshake, CERT verify (15):
    * [CONN-0-0][CF-SSL] TLSv1.2 (IN), TLS header, Supplemental data (23):
    * [CONN-0-0][CF-SSL] TLSv1.3 (IN), TLS handshake, Finished (20):
    * [CONN-0-0][CF-SSL] TLSv1.2 (OUT), TLS header, Finished (20):
    * [CONN-0-0][CF-SSL] TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
    * [CONN-0-0][CF-SSL] TLSv1.2 (OUT), TLS header, Supplemental data (23):
    * [CONN-0-0][CF-SSL] TLSv1.3 (OUT), TLS handshake, Finished (20):
    * SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
    * ALPN: server accepted http/1.1
    * Server certificate:
    *  subject: CN=front
    *  start date: Dec 27 10:49:24 2022 GMT
    *  expire date: Dec 24 10:49:24 2032 GMT
    *  issuer: CN=front
    *  SSL certificate verify result: self-signed certificate (18), continuing anyway.
    * [CONN-0-0][CF-SSL] TLSv1.2 (OUT), TLS header, Supplemental data (23):
    > GET / HTTP/1.1
    > Host: 127.0.0.1
    > User-Agent: curl/7.87.1-DEV
    > Accept: */*
    > 
    * [CONN-0-0][CF-SSL] TLSv1.2 (IN), TLS header, Supplemental data (23):
    * [CONN-0-0][CF-SSL] TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
    * [CONN-0-0][CF-SSL] TLSv1.2 (IN), TLS header, Supplemental data (23):
    * [CONN-0-0][CF-SSL] TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
    * old SSL session ID is stale, removing
    * [CONN-0-0][CF-SSL] TLSv1.2 (IN), TLS header, Supplemental data (23):
    < HTTP/1.1 200 OK
    < Date: Tue, 27 Dec 2022 11:25:40 GMT
    < Server: Apache
    < Vary: Accept-Encoding
    < X-Content-Type-Options: nosniff
    < X-Frame-Options: sameorigin
    < Content-Length: xxx
    < Content-Type: text/html; charset=UTF-8
    < 
    Hello, World
    * Connection #0 to host 127.0.0.1 left intact
  6. added a commit that references this issue on Oct 15, 2025
    db5f833
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions