You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2017/07/21 17:02:15 UTC
[19/20] qpid-proton git commit: PROTON-1400: [C++ example] Fix ssl
test example to not rely on catching a specific exception thrown out of
container::run.
PROTON-1400: [C++ example] Fix ssl test example to not rely on catching a specific exception thrown out of container::run.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/2a606538
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/2a606538
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/2a606538
Branch: refs/heads/master
Commit: 2a606538336a15da4de38684b34432e4157a02b9
Parents: e4eca5c
Author: Andrew Stitcher <as...@apache.org>
Authored: Thu Jul 13 08:42:52 2017 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Fri Jul 21 12:50:06 2017 -0400
----------------------------------------------------------------------
examples/cpp/ssl.cpp | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2a606538/examples/cpp/ssl.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/ssl.cpp b/examples/cpp/ssl.cpp
index 85dfa48..166bd61 100644
--- a/examples/cpp/ssl.cpp
+++ b/examples/cpp/ssl.cpp
@@ -50,10 +50,11 @@ ssl_certificate platform_certificate(const std::string &base_name, const std::st
std::string find_CN(const std::string &);
namespace {
- std::string verify_full("full"); // Normal verification
- std::string verify_noname("noname"); // Skip matching host name against the certificate
- std::string verify_fail("fail"); // Force name mismatch failure
+ const std::string verify_full("full"); // Normal verification
+ const std::string verify_noname("noname"); // Skip matching host name against the certificate
+ const std::string verify_fail("fail"); // Force name mismatch failure
std::string verify(verify_full); // Default for example
+ bool verify_failed(false);
std::string cert_directory;
class example_cert_error : public std::runtime_error
@@ -137,8 +138,10 @@ class hello_world_direct : public proton::messaging_handler {
void on_transport_error(proton::transport &t) OVERRIDE {
std::string err = t.error().what();
- if (err.find("certificate"))
+ if (err.find("certificate")) {
+ verify_failed = true;
throw example_cert_error(err);
+ }
}
void on_sendable(proton::sender &s) OVERRIDE {
@@ -179,13 +182,15 @@ int main(int argc, char **argv) {
hello_world_direct hwd(address);
proton::default_container(hwd).run();
return 0;
- } catch (const example_cert_error& ce) {
- if (verify == verify_fail) {
- std::cout << "Expected failure of connection with wrong peer name: " << ce.what() << std::endl;
- return 0;
- }
- std::cerr << "unexpected internal certificate failure: " << ce.what() << std::endl;
} catch (const std::exception& e) {
+ if (verify_failed) {
+ if (verify == verify_fail) {
+ std::cout << "Expected failure of connection with wrong peer name: " << e.what() << std::endl;
+ return 0;
+ } else {
+ std::cerr << "unexpected internal certificate failure: ";
+ }
+ }
std::cerr << e.what() << std::endl;
}
return 1;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org