mirror of
https://github.com/curl/curl.git
synced 2026-07-10 09:27:16 +03:00
By exposing and reusing existing custom type via `vtls/openss.h`.
Also:
- GHA/curl-for-win: test in CI by enabling building tests.
Cost is 45s per job, so limit it to the gcc job.
Seen with Windows x64 gcc (not tested in CI prior to this patch):
```
tests/libtest/lib1587.c:50:7: error: conversion from 'opt1587' {aka 'long long unsigned int'} to 'long int' may change value [-Werror=conversion]
50 | SSL_CTX_set_options(info->internals, opts);
| ^~~~~~~~~~~~~~~~~~~
tests/libtest/lib1587.c:59:7: error: conversion from 'opt1587' {aka 'long long unsigned int'} to 'long int' may change value [-Werror=conversion]
59 | SSL_set_options(info->internals, opts);
| ^~~~~~~~~~~~~~~
```
Ref: https://github.com/curl/curl/actions/runs/28258372229/job/83727170184?pr=22195#step:3:4884
Ref: da2f05e6f6 #22198
Ref: 6163566461 #22197
Follow-up to 3e40ccb875 #21290
Follow-up to 2db8ae480f #17809 #17801
Closes #22195
91 lines
2.7 KiB
C
91 lines
2.7 KiB
C
/***************************************************************************
|
|
* _ _ ____ _
|
|
* Project ___| | | | _ \| |
|
|
* / __| | | | |_) | |
|
|
* | (__| |_| | _ <| |___
|
|
* \___|\___/|_| \_\_____|
|
|
*
|
|
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
|
*
|
|
* This software is licensed as described in the file COPYING, which
|
|
* you should have received as part of this distribution. The terms
|
|
* are also available at https://curl.se/docs/copyright.html.
|
|
*
|
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
* copies of the Software, and permit persons to whom the Software is
|
|
* furnished to do so, under the terms of the COPYING file.
|
|
*
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
* KIND, either express or implied.
|
|
*
|
|
* SPDX-License-Identifier: curl
|
|
*
|
|
***************************************************************************/
|
|
#include "first.h"
|
|
|
|
#ifdef USE_OPENSSL
|
|
#include <vtls/openssl.h>
|
|
|
|
static size_t write_cb(char *ptr, size_t size, size_t nmemb, void *stream)
|
|
{
|
|
const struct curl_tlssessioninfo *info;
|
|
CURLcode result;
|
|
static int once;
|
|
CURL *curl = stream;
|
|
(void)ptr;
|
|
|
|
if(!once++) {
|
|
result = curl_easy_getinfo(curl, CURLINFO_TLS_SESSION, &info);
|
|
|
|
if(result == CURLE_OK) {
|
|
/* set and read stuff using the SSL_CTX to verify it */
|
|
ctx_option_t opts = SSL_CTX_get_options(info->internals);
|
|
SSL_CTX_set_options(info->internals, opts);
|
|
curl_mprintf("CURLINFO_TLS_SESSION: OK\n");
|
|
}
|
|
|
|
result = curl_easy_getinfo(curl, CURLINFO_TLS_SSL_PTR, &info);
|
|
|
|
if(result == CURLE_OK) {
|
|
/* set and read stuff using the SSL pointer to verify it */
|
|
ctx_option_t opts = SSL_get_options(info->internals);
|
|
SSL_set_options(info->internals, opts);
|
|
curl_mprintf("CURLINFO_TLS_SSL_PTR: OK\n");
|
|
}
|
|
}
|
|
|
|
return size * nmemb;
|
|
}
|
|
|
|
static CURLcode test_lib1587(const char *URL)
|
|
{
|
|
CURLcode result = curl_global_init(CURL_GLOBAL_ALL);
|
|
CURL *curl;
|
|
if(result)
|
|
return result;
|
|
|
|
curl = curl_easy_init();
|
|
if(curl) {
|
|
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_cb);
|
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, curl);
|
|
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
|
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
|
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
|
|
|
|
result = curl_easy_perform(curl);
|
|
curl_easy_cleanup(curl);
|
|
}
|
|
|
|
curl_global_cleanup();
|
|
|
|
return result;
|
|
}
|
|
#else
|
|
/* without OpenSSL this does nothing */
|
|
static CURLcode test_lib1587(const char *URL)
|
|
{
|
|
(void)URL;
|
|
return CURLE_OK;
|
|
}
|
|
#endif
|