Skip to content

--ca-native/CURLSSLOPT_NATIVE_CA break when cert store contains invalid certs #18190

@MichalPetryka

Description

@MichalPetryka

I did this

Enabling --ca-native/CURLSSLOPT_NATIVE_CA while using OpenSSL (backends other than OpenSSL and SChannel untested) and having invalid certs in Windows cert store makes CURL (both exe and libCurl) error out with:

curl: (35) TLS connect error: error:068000DD:asn1 encoding routines::illegal padding

This causes Serbian users to be unable to use OpenSSL based Curl since for whatever reason the Serbian government has their citizens add invalid certificates to their Windows cert store to access their services.

This has many other sources referencing the issue with either OpenSSL itself or software related to it:
openssl/openssl#16701
openssl/openssl#25023
https://www.dropboxforum.com/discussions/101001016/installation-fails-for-people-from-serbia-due-to-certificates---solution-windows/490440
https://bugs.python.org/issue45312
python/cpython#79846

Since the linked OpenSSL issues indicate they have no intention of allowing such invalid certs (which some APIs like SChannel seem to do) and suggest filtering off and ignoring such certs on application level, I believe CURL should do so either by default with --ca-native/CURLSSLOPT_NATIVE_CA or when provided with some new flags since Curl does the cert store loading by itself in:

static CURLcode import_windows_cert_store(struct Curl_easy *data,

As far as I believe ignoring such certs brings no security implications since not adding them can only cause TLS rejections, not improper acceptances so I'd propose doing it automatically with the current options.

Reproduction:

  1. Build Curl with OpenSSL backend
  2. Add the cert from http://crl.mup.gov.rs/MUPCARoot.crt to Windows cert store
  3. curl.exe --ca-native https://api.ipify.org

I expected the following

Curl is working and ignoring invalid certs that are not necessary to complete the request.

curl/libcurl version

curl 8.15.0-DEV (Windows) libcurl/8.15.0-DEV OpenSSL/3.5.1 (Schannel) zlib/1.3.1 brotli/1.1.0 zstd/1.5.7 nghttp2/1.66.0
Release-Date: [unreleased]
Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli HSTS HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz MultiSSL NTLM SPNEGO SSL SSPI threadsafe TLS-SRP Unicode UnixSockets zstd

operating system

Windows 10/11

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions