[libsoup/nacho/server-tls-cert: 1/2] ssl-test: test the peer certificate exists
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup/nacho/server-tls-cert: 1/2] ssl-test: test the peer certificate exists
- Date: Thu, 25 Nov 2021 09:19:49 +0000 (UTC)
commit 7dbc7180680b7918fd3c601a32e6e1091886da95
Author: Ignacio Casal Quinteiro <qignacio amazon com>
Date: Tue Nov 23 16:06:08 2021 +0100
ssl-test: test the peer certificate exists
tests/ssl-test.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/tests/ssl-test.c b/tests/ssl-test.c
index ecd0e63e..2b23cb93 100644
--- a/tests/ssl-test.c
+++ b/tests/ssl-test.c
@@ -162,10 +162,12 @@ do_tls_interaction_test (gconstpointer data)
GTlsDatabase *tls_db;
GTlsCertificate *certificate;
GTlsInteraction *interaction;
+ GUri *peer_uri;
GError *error = NULL;
SOUP_TEST_SKIP_IF_NO_TLS;
+ peer_uri = g_uri_parse_relative (uri, "/check-peer", SOUP_HTTP_URI_FLAGS, NULL);
session = soup_test_session_new (NULL);
tls_db = soup_session_get_tls_database (session);
g_object_set (server, "tls-database", tls_db, "tls-auth-mode", G_TLS_AUTHENTICATION_REQUIRED, NULL);
@@ -197,7 +199,7 @@ do_tls_interaction_test (gconstpointer data)
g_object_unref (interaction);
/* With a GTlsInteraction */
- msg = soup_message_new_from_uri ("GET", uri);
+ msg = soup_message_new_from_uri ("GET", peer_uri);
body = soup_test_session_async_send (session, msg, NULL, &error);
g_assert_no_error (error);
soup_test_assert_message_status (msg, SOUP_STATUS_OK);
@@ -210,6 +212,7 @@ do_tls_interaction_test (gconstpointer data)
soup_test_session_abort_unref (session);
g_object_unref (certificate);
+ g_uri_unref (peer_uri);
}
static gboolean
@@ -697,6 +700,11 @@ server_handler (SoupServer *server,
soup_server_message_set_response (msg, "text/plain",
SOUP_MEMORY_STATIC,
"ok\r\n", 4);
+
+ if (!strcmp (path, "/check-peer")) {
+ g_assert_nonnull (soup_server_message_get_tls_peer_certificate (msg));
+ g_assert_cmpuint (soup_server_message_get_tls_peer_certificate_errors (msg), ==, 0);
+ }
}
int
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]