Skip to content

curl verifies incorrect subject alternative name when contacting https proxy #12831

Description

@HsiehYuho

I did this

I tried

curl -x https://[proxy:ipv6]:8082 https://destination.hostname

It gives me SAN match failure.

SSL:no alternative certificate subject name matches target hostname [proxy:ipv6]

However, the [proxy:ipv6] is in the proxy cert SAN field.
When switching to

curl -x https://[proxy:ipv6]:8082 https://[destination.ipv6]

the curl succeeds.

We (my colleagues and me) are suspecting checks around here https://github.com/curl/curl/blob/master/lib/vtls/openssl.c#L2152 lead to that curl only checks the proxy SAN type that is same as the destination type

I expected the following

curl -x https://[proxy:ipv6]:8082 https://destination.hostname 
curl -x https://[proxy:ipv6]:8082 https://[destination.ipv6]

should at least give me the same result

curl/libcurl version

curl 7.61.1 (x86_64-redhat-linux-gnu)

operating system

Linux, but our company (meta) dev our own linux ..

Activity

  1. HsiehYuho commented on Jan 31, 2024

    @HsiehYuho
    Author

    I didn't spend time working on a repro but we fairly sure that there is at least inconsistent output where there shouldn't be.

  2. dfandrich commented on Jan 31, 2024

    @dfandrich
    Contributor
  3. HsiehYuho commented on Jan 31, 2024

    @HsiehYuho
    Author

    Hi Dan,
    Yes, it is reproducible using the latest curl

    ./src/.libs/curl --version
    curl 8.6.0-DEV (x86_64-pc-linux-gnu) 
    

    we are using openssl.

  4. icing commented on Feb 1, 2024

    @icing
    Contributor

    @HsiehYuho I added a test case using '127.0.0.1' for the proxy and gave it a certificate with a x590 IPAddress in the alt names. This test works with curl 8.6.0.

    Could you recheck your findings? Is there anything specific in your ipv6 address spec that we may not account for?

  5. knekritz commented on Feb 9, 2024

    @knekritz

    @icing I think the issue is specific to IPv6 because of the conn->bits.ipv6_ip check at

    if(conn->bits.ipv6_ip &&

  6. icing commented on Feb 13, 2024

    @icing
    Contributor

    @knekritz, @HsiehYuho thanks, that is exactly the right spot. Would you be able to verify that #12931 fixes the issue for you as well?

  7. HsiehYuho commented on Feb 14, 2024

    @HsiehYuho
    Author

    @icing i tried to verify it. I git clone your branch and follow https://github.com/curl/curl/blob/master/GIT-INFO to make the binary, then execute it through

    [yhhsieh@mydev ~/curl (proxy-ipv6-cert-check)]$ ./src/.libs/curl telnet://DESTINATION_HOSTNAME:PORT -p -x  https://[PROXY:IPV6]:8082  --proxy-cert $PROXY_CERT --proxy-key $PRXOY_KEY -vvv 
    

    but it seems not hit you fix. I suspect my build is wrong. the ./src/.libs/curl was built but the commit seems not applied. Did i do anything wrong ?

  8. jay commented on Feb 14, 2024

    @jay
    Member

    ./src/.libs/curl

    Use src/curl instead, which may be a libtool wrapper script that uses LD_LIBRARY_PATH to load the libcurl that's in lib/.libs

  9. icing commented on Feb 14, 2024

    @icing
    Contributor

    @HsiehYuho if you run ./src/curl with options -v --trace-config all and your other arguments, what is the output?

  10. HsiehYuho commented on Feb 15, 2024

    @HsiehYuho
    Author

    @jay @icing thank you guys so much! Yes if i replace with ./src/curl then the fix kicks in and works! I think the fix is the right one!

  11. added a commit that references this issue on Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions