Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mbedTLS: BADCERT_CN_MISMATCH on https://1.1.1.1 with curl+mbedtls #19677

Open
busylog opened this issue Oct 22, 2022 · 9 comments
Open

mbedTLS: BADCERT_CN_MISMATCH on https://1.1.1.1 with curl+mbedtls #19677

busylog opened this issue Oct 22, 2022 · 9 comments

Comments

@busylog
Copy link

busylog commented Oct 22, 2022

Maintainer: @stangri
Environment: openwrt 22.03.2 raspberry pi 3 bcm2710

Description:

curl -V
curl 7.85.0 (aarch64-openwrt-linux-gnu) libcurl/7.85.0 mbedTLS/2.28.1 nghttp2/1.44.0
Release-Date: 2022-08-31
Protocols: file ftp ftps http https mqtt
Features: alt-svc HSTS HTTP2 IPv6 Largefile MultiSSL SSL threadsafe

opkg list-installed|grep curl
curl - 7.85.0-6.1
libcurl4 - 7.85.0-6.1

curl https://1.1.1.1/ -v
* Cert verify failed: BADCERT_CN_MISMATCH
curl: (60) Cert verify failed: BADCERT_CN_MISMATCH
More details here: https://curl.se/docs/sslcerts.html

note: https://one.one.one.one/ works. ubuntu with openssl works.

limited by mbedTLS?

@busylog
Copy link
Author

busylog commented Oct 22, 2022

seems the blocker is at Mbed-TLS/mbedtls#2906

the remaining question: net/curl/Config.in says default LIBCURL_MBEDTLS.
blame leads to 0a65e4c

busylog referenced this issue Oct 22, 2022
The decision to switch the default to wolfSSL was taken because of
hostapd back from when curl was in base. Unfortunately, not only is
wolfSSL bigger but it has also been causing issues recently. There's
also no relation between hostapd and curl.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
@stangri
Copy link
Member

stangri commented Oct 22, 2022

Sorry, what's the actual curl issue you're reporting?

@neheb
Copy link
Contributor

neheb commented Oct 23, 2022

curl+mbedtls apparently does not work with numerical domains. Sounds like mbedtls should be fixed rather than curl.

@gstrauss any input on this?

@gstrauss
Copy link
Contributor

Mbed-TLS/mbedtls#6473 was closed with a pointer to Mbed-TLS/mbedtls#5082

I'll try to read through these this week:
Mbed-TLS/mbedtls#2906
Mbed-TLS/mbedtls#5082

At first (really quick) glance, extending mbedtls to handle this might be a small change in library/x509_crt.c:x509_crt_check_san() to handle MBEDTLS_X509_SAN_IP_ADDRESS in addition to MBEDTLS_X509_SAN_DNS_NAME, plus adding tests to the mbedtls test suite.

@gstrauss
Copy link
Contributor

@neheb I submitted a PR to mbedtls in Mbed-TLS/mbedtls#6475

Since the PR is a feature addition, it is unlikely to be backported to mbedtls 2.28.1. However, I have checked that the patches apply cleanly to mbedtls 2.28.1, so you are are welcome to see if those patches allow curl with (patched) mbedtls to access 1.1.1.1 without BADCERT_CN_MISMATCH.

Note: my PR above does require a modern system which provides inet_pton(), which is true of modern openwrt, but not necessarily true of all embedded systems environments. I expect that the mbedtls team will request any number of portability changes before the PR might be accepted into mbedtls 3.x

@stangri stangri changed the title curl: (maybe mbedTLS?) BADCERT_CN_MISMATCH on https://1.1.1.1 mbedTLS: BADCERT_CN_MISMATCH on https://1.1.1.1 with curl+mbedtls Oct 24, 2022
@stangri
Copy link
Member

stangri commented Oct 24, 2022

Updated the title to reflect the current status of the issue. If the patch is needed, it would be against the OpenWrt version of mbedtls, not curl, right?

@neheb
Copy link
Contributor

neheb commented Oct 24, 2022

Yes

@neheb
Copy link
Contributor

neheb commented Nov 10, 2022

@busylog did you test this?

hauke pushed a commit to gstrauss/openwrt-libs that referenced this issue Feb 3, 2023
backport from
X509 crt verify SAN iPAddress
Mbed-TLS/mbedtls#6475

addresses
curl built with mbedtls fails on https://1.1.1.1/ (IP address in SubjectAltName)
Mbed-TLS/mbedtls#6473

filed for
mbedTLS: BADCERT_CN_MISMATCH on https://1.1.1.1 with curl+mbedtls
openwrt/packages#19677

Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
ABu33 pushed a commit to ABu33/openwrt that referenced this issue Feb 3, 2023
backport from
X509 crt verify SAN iPAddress
Mbed-TLS/mbedtls#6475

addresses
curl built with mbedtls fails on https://1.1.1.1/ (IP address in SubjectAltName)
Mbed-TLS/mbedtls#6473

filed for
mbedTLS: BADCERT_CN_MISMATCH on https://1.1.1.1 with curl+mbedtls
openwrt/packages#19677

Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
Vladdrako pushed a commit to Vladdrako/openwrt that referenced this issue Feb 5, 2023
backport from
X509 crt verify SAN iPAddress
Mbed-TLS/mbedtls#6475

addresses
curl built with mbedtls fails on https://1.1.1.1/ (IP address in SubjectAltName)
Mbed-TLS/mbedtls#6473

filed for
mbedTLS: BADCERT_CN_MISMATCH on https://1.1.1.1 with curl+mbedtls
openwrt/packages#19677

Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
Arie pushed a commit to Arie/openwrt-rb5009 that referenced this issue Feb 8, 2023
backport from
X509 crt verify SAN iPAddress
Mbed-TLS/mbedtls#6475

addresses
curl built with mbedtls fails on https://1.1.1.1/ (IP address in SubjectAltName)
Mbed-TLS/mbedtls#6473

filed for
mbedTLS: BADCERT_CN_MISMATCH on https://1.1.1.1 with curl+mbedtls
openwrt/packages#19677

Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
1582130940 pushed a commit to 1582130940/OpenWrt-Lean that referenced this issue Mar 2, 2023
backport from
X509 crt verify SAN iPAddress
Mbed-TLS/mbedtls#6475

addresses
curl built with mbedtls fails on https://1.1.1.1/ (IP address in SubjectAltName)
Mbed-TLS/mbedtls#6473

filed for
mbedTLS: BADCERT_CN_MISMATCH on https://1.1.1.1 with curl+mbedtls
openwrt/packages#19677

Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
1582130940 pushed a commit to 1582130940/OpenWrt-Lean that referenced this issue Mar 9, 2023
backport from
X509 crt verify SAN iPAddress
Mbed-TLS/mbedtls#6475

addresses
curl built with mbedtls fails on https://1.1.1.1/ (IP address in SubjectAltName)
Mbed-TLS/mbedtls#6473

filed for
mbedTLS: BADCERT_CN_MISMATCH on https://1.1.1.1 with curl+mbedtls
openwrt/packages#19677

Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
1582130940 pushed a commit to 1582130940/OpenWrt-Lean that referenced this issue Mar 10, 2023
backport from
X509 crt verify SAN iPAddress
Mbed-TLS/mbedtls#6475

addresses
curl built with mbedtls fails on https://1.1.1.1/ (IP address in SubjectAltName)
Mbed-TLS/mbedtls#6473

filed for
mbedTLS: BADCERT_CN_MISMATCH on https://1.1.1.1 with curl+mbedtls
openwrt/packages#19677

Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
1582130940 pushed a commit to 1582130940/OpenWrt-Lean that referenced this issue Mar 15, 2023
backport from
X509 crt verify SAN iPAddress
Mbed-TLS/mbedtls#6475

addresses
curl built with mbedtls fails on https://1.1.1.1/ (IP address in SubjectAltName)
Mbed-TLS/mbedtls#6473

filed for
mbedTLS: BADCERT_CN_MISMATCH on https://1.1.1.1 with curl+mbedtls
openwrt/packages#19677

Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
1582130940 pushed a commit to 1582130940/OpenWrt-Lean that referenced this issue Mar 17, 2023
backport from
X509 crt verify SAN iPAddress
Mbed-TLS/mbedtls#6475

addresses
curl built with mbedtls fails on https://1.1.1.1/ (IP address in SubjectAltName)
Mbed-TLS/mbedtls#6473

filed for
mbedTLS: BADCERT_CN_MISMATCH on https://1.1.1.1 with curl+mbedtls
openwrt/packages#19677

Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
1582130940 pushed a commit to 1582130940/OpenWrt-Lean that referenced this issue Mar 17, 2023
backport from
X509 crt verify SAN iPAddress
Mbed-TLS/mbedtls#6475

addresses
curl built with mbedtls fails on https://1.1.1.1/ (IP address in SubjectAltName)
Mbed-TLS/mbedtls#6473

filed for
mbedTLS: BADCERT_CN_MISMATCH on https://1.1.1.1 with curl+mbedtls
openwrt/packages#19677

Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
1582130940 pushed a commit to 1582130940/OpenWrt-Lean that referenced this issue Mar 17, 2023
backport from
X509 crt verify SAN iPAddress
Mbed-TLS/mbedtls#6475

addresses
curl built with mbedtls fails on https://1.1.1.1/ (IP address in SubjectAltName)
Mbed-TLS/mbedtls#6473

filed for
mbedTLS: BADCERT_CN_MISMATCH on https://1.1.1.1 with curl+mbedtls
openwrt/packages#19677

Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
1582130940 pushed a commit to 1582130940/OpenWrt-Lean that referenced this issue Mar 18, 2023
backport from
X509 crt verify SAN iPAddress
Mbed-TLS/mbedtls#6475

addresses
curl built with mbedtls fails on https://1.1.1.1/ (IP address in SubjectAltName)
Mbed-TLS/mbedtls#6473

filed for
mbedTLS: BADCERT_CN_MISMATCH on https://1.1.1.1 with curl+mbedtls
openwrt/packages#19677

Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
@stangri
Copy link
Member

stangri commented Aug 30, 2023

@busylog can you still reproduce with updated mbedtls?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants