[glibmm] Tls Client Test: Update to test the TlsDatabase class.
- From: José Alburquerque <jaalburqu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] Tls Client Test: Update to test the TlsDatabase class.
- Date: Fri, 12 Apr 2013 04:15:13 +0000 (UTC)
commit 81a37f0ee0f7ac8796fdb7e7905e338a597f5d07
Author: José Alburquerque <jaalburqu svn gnome org>
Date: Fri Apr 12 00:12:48 2013 -0400
Tls Client Test: Update to test the TlsDatabase class.
* tests/giomm_tls_client/main.cc: Slightly cleaned it up from the
first commit. Lookup the issuer's certificate in the database which
is found when I run the test.
ChangeLog | 8 ++++++
tests/giomm_tls_client/main.cc | 48 +++++++++++++++------------------------
2 files changed, 27 insertions(+), 29 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 033ae05..cc19c1d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2013-04-12 José Alburquerque <jaalburquerque gmail com>
+ Tls Client Test: Update to test the TlsDatabase class.
+
+ * tests/giomm_tls_client/main.cc: Slightly cleaned it up from the
+ first commit. Lookup the issuer's certificate in the database which
+ is found when I run the test.
+
+2013-04-12 José Alburquerque <jaalburquerque gmail com>
+
TlsDatabase: Make sure the cancellable param is optional in methods.
* gio/src/tlsdatabase.hg: Use the {.?} gmmproc parameter option for
diff --git a/tests/giomm_tls_client/main.cc b/tests/giomm_tls_client/main.cc
index dc69a4a..a6f43d4 100644
--- a/tests/giomm_tls_client/main.cc
+++ b/tests/giomm_tls_client/main.cc
@@ -16,7 +16,9 @@ bool on_accept_certificate(const Glib::RefPtr<const Gio::TlsCertificate>& cert,
std::cout << "Outputing the issuer's certificate data:" << std::endl <<
issuer->property_certificate_pem().get_value();
- std::cout << "Accepting the certificate." << std::endl;
+ std::cout << "Accepting the certificate (completing the handshake)." <<
+ std::endl;
+
return true;
}
@@ -87,49 +89,37 @@ int main(int, char**)
tls_connection->handshake();
- Glib::RefPtr<Gio::TlsCertificate> certificate =
- tls_connection->get_peer_certificate();
+ std::cout << "Attempting to get the issuer's certificate from the "
+ "connection." << std::endl;
- if(!certificate)
- {
- std::cout << "Could not get the peer's certificate." << std::endl;
- }
+ Glib::RefPtr<Gio::TlsCertificate> issuer_certificate =
+ tls_connection->get_peer_certificate()->get_issuer();
- std::cout << "Successfully got the peer's certificate." << std::endl;
- std::cout << "Getting the certificate's issuer." << std::endl;
-
- Glib::RefPtr<Gio::TlsCertificate> issuer = certificate->get_issuer();
-
- if(!issuer)
+ if(!issuer_certificate)
{
- std::cout << "Could not get the peer's certificate." << std::endl;
+ std::cout << "Could not get the issuer's certificate of the peer." <<
+ std::endl;
+ return EXIT_FAILURE;
}
-
- std::cout << "Successfully got the peer's certificate issuer." << std::endl;
+ std::cout << "Successfully retrieved the issuer's certificate." <<
+ std::endl;
std::cout << "Attempting to use the connection's database." << std::endl;
-
Glib::RefPtr<Gio::TlsDatabase> database = tls_connection->get_database();
- Glib::RefPtr<const Gio::SocketConnectable> connectable = address;
-
- database->verify_chain(certificate, G_TLS_DATABASE_PURPOSE_AUTHENTICATE_SERVER, connectable);
-
- database->verify_chain(certificate, G_TLS_DATABASE_PURPOSE_AUTHENTICATE_SERVER, Glib::RefPtr<const
Gio::SocketConnectable>::cast_static(address));
-
- std::cout << "Looking up the main certificate's issuer in the "
- "database." << std::endl;
+ std::cout << "Looking up the certificate's issuer in the database." <<
+ std::endl;
- Glib::RefPtr<Gio::TlsCertificate> db_certificate = database->lookup_certificate_issuer(certificate);
+ Glib::RefPtr<Gio::TlsCertificate> db_certificate =
+ database->lookup_certificate_issuer(issuer_certificate);
if(!db_certificate)
{
- std::cout << "No certificate found in the database." << std::endl;
+ std::cout << "The issuer's certificate was not found in the database." << std::endl;
}
else
{
- std::cout << "Successfully found the issuer's certificate in the "
- "database." << std::endl;
+ std::cout << "Successfully found the issuer's certificate in the database." << std::endl;
}
}
catch (const Gio::TlsError& error)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]