1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-08 14:02:17 +03:00

11 Commits

Author SHA1 Message Date
Vladislav Vaintroub
76564675fc Merge 3.1 into 3.3 2024-11-07 08:47:12 +01:00
Vladislav Vaintroub
b1f1267805 CONC-527 post-fix.
Add fallback if CryptAcquireContext fails with ERROR_ACCESS_DENIED,
as seen in Jenkins CI.

The fallback, also suggested by https://stackoverflow.com/a/14053718/547065,
is to retry with machine-wide key container, if user-specific fails.
2024-11-07 08:30:59 +01:00
Vladislav Vaintroub
1e8e1f4f38 Fix "set but not used" warnings. 2024-07-31 20:48:44 +02:00
Vladislav Vaintroub
72116a30ab Merge branch '3.1' into 3.3 2024-07-29 11:53:15 +02:00
Vladislav Vaintroub
6a67a34f47 CONC-527 "SEC_E_ALGORITHM_MISMATCH" connecting Windows client to Ubuntu
The bug happens only when connecting with SSL with client certificates.

Apparently if client certificates are used in TLS handshake,
private keys for cert should be loaded into named persistent
container.This is because AcquireCredentialsHandle is done partically
out-of-process in lsass.exe, and lsass wants to read private keys from disk

See discussion in https://github.com/dotnet/runtime/issues/23749

Schannel has legacy behavior for ephemeral keys, not involving lsass,
and this is why it worked for us so far, however there are limitations.

It appears to only use rsa_sha1 for signature verification, and newer
OpenSSL no longer allows SHA1 for it, and this ends up in
"algorithm mismatch" message from schannel.

The above is just my understanding of how it works, because there is no
real documentation, the conclusion is based on discussion in
https://github.com/dotnet/runtime/issues/23749

The fix:
So storing the key in persistent named container evidently fixes it,
and this is what is done in this patch. Care is takes to destroy
key container after key is no longer needed, to
avoid filling  %AppData%\Roaming\Microsoft\Crypto\RSA with tiny encrypted
key files. Thus the "persistency window" of the key in container on disk
is only for duration of AcquireCredentialsHandle
2024-07-28 03:46:50 +02:00
Vladislav Vaintroub
4692e9cec1 CONC-645 : fix build with clang (v16), clang-cl(v16), and mingw-gcc(v12).
schannel_certs.c - conflicting headers, include winsock2.h before windows.h,

strerror_r is now defined also with mingw

do not build mariadb_config on Windows, getopt.h is missing
2023-09-22 00:59:48 +02:00
Vladislav Vaintroub
802ce584a2 CONC-555 appverifier error in schannel_free_cert_context
It looks like CertFreeCertificateContext() would try to access
freed memory.

Fix it by using CERT_STORE_NO_CRYPT_RELEASE_FLAG when setting private key
in certificate, i.e avoid releasing the crypto provider when certificate
is freed.

Note:
My attempts to fix with less code , i.e just omit CryptReleaseContext(),
failed, there was a small memory leak left after freeing each SSL
connection.
2021-06-14 22:45:19 +02:00
Georg Richter
820faff627 codespell fixes, removed MSDOS preprocessor macros 2020-11-26 09:07:17 +01:00
Vladislav Vaintroub
777460c226 Fix C11 conformance
Ellipsis in variadic macro requires at least 1 argument
2020-11-12 23:24:19 +00:00
Vladislav Vaintroub
2efc52b5b7 Fix clang-tidy warnings.
simplify error handling in schannel_certs.c
2019-12-09 00:22:46 +01:00
Vladislav Vaintroub
63df45ce3d CONC-447 ERROR 2026 (HY000): SSL connection error: Certificate signature check failed
Implement proper verification for server certificate chain,
with refactoring of the certificate stuff.

If custom CA and CRL certs are given, load them into in-memory store, and
use CertVerifyCertificateChainPolicy() to verify the certificate chain.

There are minor errors fixed, such as
- now there is a support for private keys encoded as BEGIN/END PRIVATE KEY
in PEM, instead of only BEGIN/END RSA PRIVATE KEY
- memory leak around CryptAcquireContext() is fixed i.e when client loads
private key, it previously did never released it, not even when connection
ended.

The handling of certificates moved into schannel_certs.c from various places
2019-12-08 18:07:48 +01:00