Commit 384c678
authored
[eval] Fix ssl cert verification failures on clean windows environments (#11838)
* Use windows api to verify ssl certs
Taken from:
Apprentice-Alchemist/hashlink@4d59012
* Handle error if cert store fails to open
* Fix mscv warnings about invalid arguments
Warning C6387 'parameters' could be '0': this does not adhere to the specification for the function 'CertGetCertificateChain'.
Warning C6387 'policy_parameters' could be '0': this does not adhere to the specification for the function 'CertVerifyCertificateChainPolicy'.
This also fixes an "incorrect parameter" runtime error.
* Clear errors if certificate loading succeeded
* Perform checks for all calls of verify_callback
We need to do this every time, because if any callback call returns a
non zero flags then the entire verification fails, see:
https://github.com/Mbed-TLS/mbedtls/blob/3aefa5b705846c5d4466ae8747160ae9e5054ea8/library/x509_crt.c#L3031
We don't need to loop through the chain, since mbedtls already loops
through and calls the callback on every certificate in the chain.
* Free handles on certificate verification errors
* Replace existing certificates if they exist
This avoids duplicate certificates in the store
* Propagate CN_MISMATCH ssl cert error
The windows api functions won't check this automatically for us without
further modifications, so it's easiest to just respect mbedtls'
judgement and propagate this error.
* Clarify comment regarding error mapping
* Skip verification callback if no errors were found1 parent 13ebeff commit 384c678
1 file changed
+47
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
305 | 349 | | |
306 | 350 | | |
307 | 351 | | |
308 | 352 | | |
309 | 353 | | |
310 | 354 | | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
311 | 358 | | |
312 | 359 | | |
313 | 360 | | |
| |||
0 commit comments