summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJosé Alburquerque <jaalburqu@svn.gnome.org>2013-04-12 00:12:48 -0400
committerJosé Alburquerque <jaalburqu@svn.gnome.org>2013-04-12 00:12:48 -0400
commit81a37f0ee0f7ac8796fdb7e7905e338a597f5d07 (patch)
treea3b1c23156709a9b0159b8880744565e0d96a0bc /tests
parent5c6cb789efb4908faa6bcfbfeab4d52431834a3e (diff)
downloadglibmm-81a37f0ee0f7ac8796fdb7e7905e338a597f5d07.tar.gz
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/giomm_tls_client/main.cc48
1 files changed, 19 insertions, 29 deletions
diff --git a/tests/giomm_tls_client/main.cc b/tests/giomm_tls_client/main.cc
index dc69a4a2..a6f43d49 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)