@@ -672,7 +672,9 @@ static int test_cert_wildcard(MYSQL *my __attribute((unused)))
672
672
if (!my_test_connect(mysql, tls_dummy_host, "tlsuser", "foo", NULL, tls_dummy_port, NULL, 0, 0))
673
673
{
674
674
CHECK_NO_TLS_FLAG(mysql, MARIADB_TLS_VERIFY_HOST, "Hostname verification didn't pass");
675
+ #ifndef HAVE_SCHANNEL
675
676
CHECK_TLS_FLAGS(mysql, MARIADB_TLS_VERIFY_TRUST, "Self signed certificate expected");
677
+ #endif
676
678
mysql_close(mysql);
677
679
} else {
678
680
mysql_close(mysql);
@@ -699,12 +701,91 @@ static int test_cert_wildcard(MYSQL *my __attribute((unused)))
699
701
return OK;
700
702
}
701
703
704
+ static int test_env_var(MYSQL *my __attribute__((unused)))
705
+ {
706
+ MYSQL *mysql= mysql_init(NULL);
707
+ int rc= FAIL;
708
+ unsigned int status;
709
+
710
+ #ifdef _WIN32
711
+ _putenv_s("MARIADB_TLS_DISABLE_PEER_VERIFICATION", "1");
712
+ #else
713
+ setenv("MARIADB_TLS_DISABLE_PEER_VERIFICATION", "1", 1);
714
+ #endif
715
+
716
+ if (!my_test_connect(mysql, hostname, username, password, schema,
717
+ port, socketname, 0, 0))
718
+ {
719
+ diag("expected to pass, since environment variable was set");
720
+ goto end;
721
+ }
722
+
723
+ mariadb_get_infov(mysql, MARIADB_TLS_VERIFY_STATUS, &status);
724
+
725
+ if (status)
726
+ {
727
+ diag("expected status=0, since environment variable was set");
728
+ goto end;
729
+ }
730
+
731
+ rc= OK;
732
+
733
+ end:
734
+ #ifdef _WIN32
735
+ _putenv_s("MARIADB_TLS_DISABLE_PEER_VERIFICATION", "");
736
+ #else
737
+ unsetenv("MARIADB_TLS_DISABLE_PEER_VERIFICATION");
738
+ #endif
739
+ mysql_close(mysql);
740
+ return rc;
741
+ }
742
+
743
+ static int test_fp_and_verify(MYSQL *my __attribute__((unused)))
744
+ {
745
+ MYSQL *mysql= mysql_init(NULL);
746
+ int rc= FAIL;
747
+ #ifndef HAVE_SCHANNEL
748
+ unsigned int status;
749
+ #endif
750
+ my_bool verify= 1;
751
+
752
+ mysql_options(mysql, MARIADB_OPT_SSL_FP, fingerprint);
753
+ mysql_options(mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, &verify);
754
+
755
+ if (!my_test_connect(mysql, hostname, username, password, schema,
756
+ port, socketname, 0, 0))
757
+ {
758
+ diag("expected to pass, since fingerprint was specified");
759
+ diag("error: %s", mysql_error(mysql));
760
+ goto end;
761
+ }
762
+
763
+ /* Schannel aborts on first error, if fingerprint was specified,
764
+ MARIADB_TLS_VERIFY_TRUST is unset */
765
+ #ifndef HAVE_SCHANNEL
766
+ mariadb_get_infov(mysql, MARIADB_TLS_VERIFY_STATUS, &status);
767
+
768
+ if (!status)
769
+ {
770
+ diag("expected status flag set (self signed)");
771
+ goto end;
772
+ }
773
+ #endif
774
+ rc= OK;
775
+
776
+ end:
777
+ mysql_close(mysql);
778
+ return rc;
779
+ }
780
+
702
781
703
782
struct my_tests_st my_tests[] = {
704
783
/* Don't add test above, test_init needs to be run first */
705
784
{"test_start_tls_server", test_start_tls_server, TEST_CONNECTION_NONE, 0, NULL, NULL},
706
785
{"test_init", test_init, TEST_CONNECTION_NONE, 0, NULL, NULL},
707
786
/* Here you can add more tests */
787
+ {"test_fp_and_verify", test_fp_and_verify, TEST_CONNECTION_NEW, 0, NULL, NULL},
788
+ {"test_env_var", test_env_var, TEST_CONNECTION_NEW, 0, NULL, NULL},
708
789
{"test_cert_wildcard", test_cert_wildcard, TEST_CONNECTION_NEW, 0, NULL, NULL},
709
790
{"test_cert_expired", test_cert_expired, TEST_CONNECTION_NEW, 0, NULL, NULL},
710
791
{"test_pw_check", test_pw_check, TEST_CONNECTION_NEW, 0, NULL, NULL},
0 commit comments