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 test2.cpp
  • Loading branch information
ihsinme authored Jul 3, 2022
commit 6c9936c128f1114c6656c0da70453a6c9cd89f91
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
namespace std
{
class string{};
}
namespace boost
{
namespace asio
@@ -14,13 +10,13 @@ namespace boost
{
public:
typedef bool result_type;
explicit rfc2818_verification(const std::string& host) {}
explicit rfc2818_verification(const char * host) {}
};
class host_name_verification
{
public:
typedef bool result_type;
explicit host_name_verification(const std::string& host) {}
explicit host_name_verification(const char * host) {}
};
class stream
{
@@ -33,6 +29,15 @@ namespace boost
}
}
}

void goodTest1(boost::asio::ssl::stream sock){ // GOOD
sock.set_verify_mode(boost::asio::ssl::verify_peer);
sock.set_verify_callback(boost::asio::ssl::host_name_verification("host.name"));
}
void goodTest2(boost::asio::ssl::stream sock){ // GOOD
sock.set_verify_mode(boost::asio::ssl::verify_peer);
sock.set_verify_callback(boost::asio::ssl::rfc2818_verification("host.name"));
}
void badTest1(boost::asio::ssl::stream sock){ // BAD
sock.set_verify_mode(boost::asio::ssl::verify_peer);
}