08-ssl-fake-cacert.cpp 841 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include <errno.h>
  2. #include <mosquittopp.h>
  3. static int run = -1;
  4. class mosquittopp_test : public mosqpp::mosquittopp
  5. {
  6. public:
  7. mosquittopp_test(const char *id);
  8. void on_connect(int rc);
  9. };
  10. mosquittopp_test::mosquittopp_test(const char *id) : mosqpp::mosquittopp(id)
  11. {
  12. }
  13. void mosquittopp_test::on_connect(int rc)
  14. {
  15. exit(1);
  16. }
  17. int main(int argc, char *argv[])
  18. {
  19. struct mosquittopp_test *mosq;
  20. int rc;
  21. int port = atoi(argv[1]);
  22. mosqpp::lib_init();
  23. mosq = new mosquittopp_test("08-ssl-fake-cacert");
  24. mosq->tls_opts_set(1, "tlsv1", NULL);
  25. mosq->tls_set("../ssl/test-fake-root-ca.crt", NULL, "../ssl/client.crt", "../ssl/client.key");
  26. mosq->connect("localhost", port, 60);
  27. rc = mosq->loop_forever();
  28. delete mosq;
  29. mosqpp::lib_cleanup();
  30. if(rc == MOSQ_ERR_ERRNO && errno == EPROTO){
  31. return 0;
  32. }else{
  33. return 1;
  34. }
  35. }