test1587: verify

This commit is contained in:
Daniel Stenberg 2026-04-10 22:58:54 +02:00
parent 62ef55d64f
commit 8574e93fa6
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
4 changed files with 145 additions and 3 deletions

View File

@ -208,7 +208,7 @@ test1548 test1549 test1550 test1551 test1552 test1553 test1554 test1555 \
test1556 test1557 test1558 test1559 test1560 test1561 test1562 test1563 \
test1564 test1565 test1566 test1567 test1568 test1569 test1570 test1571 \
test1572 test1573 test1574 test1575 test1576 test1577 test1578 test1579 \
test1580 test1581 test1582 test1583 test1584 test1585 test1586 \
test1580 test1581 test1582 test1583 test1584 test1585 test1586 test1587 \
\
test1590 test1591 test1592 test1593 test1594 test1595 test1596 test1597 \
test1598 test1599 test1600 test1601 test1602 test1603 test1604 test1605 \

51
tests/data/test1587 Normal file
View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="US-ASCII"?>
<testcase>
<info>
<keywords>
HTTPS
CURLINFO_TLS_SESSION
</keywords>
</info>
# Server-side
<reply>
<data crlf="headers" nocheck="yes">
HTTP/1.1 401 OK
Date: Tue, 09 Nov 2030 14:49:00 GMT
Server: test-server/fake
Content-Length: 7
WWW-Authenticate: curl2000
nomnom
</data>
</reply>
# Client-side
<client>
<features>
SSL
OpenSSL
</features>
<server>
http
https
</server>
<name>
CURLINFO_TLS_SESSION and CURLINFO_TLS_SSL_PTR with OpenSSL
</name>
<tool>
lib%TESTNUMBER
</tool>
<command>
https://%HOSTIP:%HTTPSPORT/
</command>
</client>
<verify>
<stdout mode="text">
CURLINFO_TLS_SESSION: OK
CURLINFO_TLS_SSL_PTR: OK
</stdout>
</verify>
</testcase>

View File

@ -96,8 +96,7 @@ TESTS_C = \
lib1552.c lib1553.c lib1554.c lib1555.c lib1556.c lib1557.c lib1558.c \
lib1559.c lib1560.c lib1564.c lib1565.c \
lib1567.c lib1568.c lib1569.c lib1571.c \
lib1576.c \
lib1582.c \
lib1576.c lib1582.c lib1587.c \
lib1591.c lib1592.c lib1593.c lib1594.c lib1597.c \
lib1598.c lib1599.c \
lib1662.c \

92
tests/libtest/lib1587.c Normal file
View File

@ -0,0 +1,92 @@
/***************************************************************************
* _ _ ____ _
* 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 <stdio.h>
#include <curl/curl.h>
static size_t write_cb(char *ptr, size_t size, size_t nmemb, void *stream)
{
const struct curl_tlssessioninfo *info;
CURLcode result;
CURL *curl = stream;
(void)ptr;
result = curl_easy_getinfo(curl, CURLINFO_TLS_SESSION, &info);
if(result == CURLE_OK) {
/* set and read stuff using the SSL_CTX to verify it */
SSL_CTX_set_security_level(info->internals, 5);
SSL_CTX_get_security_level(info->internals);
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 */
SSL_set_security_level(info->internals, 5);
SSL_get_security_level(info->internals);
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 != CURLE_OK)
return (int)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 (int)result;
}
#else
/* without OpenSSL this does nothing */
static CURLcode test_lib1587(const char *URL)
{
(void)URL;
return CURLE_OK;
}
#endif