Skip to content

CPP: Add query for CWE-297: Improper Validation of Certificate with Host Mismatch #9086

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update test1.cpp
  • Loading branch information
ihsinme authored Jun 26, 2022
commit d09de269a0e19d0e918399da99a61f819fbf3f7f
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@ int gnutls_x509_crt_check_hostname2(gnutls_x509_crt_t cert,const char *hostname,
int gnutls_certificate_verify_peers(gnutls_session_t session);
int gnutls_certificate_verify_peers2(gnutls_session_t session, int * status);
int gnutls_certificate_verify_peers3(gnutls_session_t session, const char * hostname, int * status);
/*
int goodTest1(gnutls_session_t session, gnutls_x509_crt_t cert){ // GOOD
if(gnutls_certificate_verify_peers(session)<0)
return 1;
@@ -35,7 +34,7 @@ int goodTest3(gnutls_session_t session, gnutls_x509_crt_t cert){ // GOOD
return 1;
if (gnutls_x509_crt_init (&cert) < 0)
return 1;
if (!gnutls_x509_crt_check_hostname2 (cert, "hostname"))
if (!gnutls_x509_crt_check_hostname2 (cert, "hostname", status))
return 1;
return 0;
}
@@ -45,7 +44,6 @@ int goodTest4(gnutls_session_t session){ // GOOD
return 1;
return 0;
}
*/
int badTest1(gnutls_session_t session){ // BAD
int status;
if(gnutls_certificate_verify_peers3(session,NULL,&status)<0)