[S] Change in openvpn[master]: verify_x509_name: Improve the error message on failure
"selvanair (Code Review)" <[email protected]>
| Newsgroups | gmane.network.openvpn.devel |
|---|---|
| Message-ID | <[email protected]> |
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/1624?usp=email
to review the following change.
Change subject: verify_x509_name: Improve the error message on failure
......................................................................
verify_x509_name: Improve the error message on failure
Print the actual string that was used for the match instead of the
whole subject.
Github: closes OpenVPN/openvpn#992
Change-Id: I6e7947ab81cf229f0d27714dd563a07ace6bd38a
Signed-off-by: Selva Nair <[email protected]>
---
M src/openvpn/ssl_verify.c
1 file changed, 22 insertions(+), 11 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/24/1624/1
diff --git a/src/openvpn/ssl_verify.c b/src/openvpn/ssl_verify.c
index d44f25f..21b516d 100644
--- a/src/openvpn/ssl_verify.c
+++ b/src/openvpn/ssl_verify.c
@@ -369,21 +369,32 @@
/* verify X509 name or username against --verify-x509-[user]name */
if (opt->verify_x509_type != VERIFY_X509_NONE)
{
- if ((opt->verify_x509_type == VERIFY_X509_SUBJECT_DN
- && strcmp(opt->verify_x509_name, subject) == 0)
- || (opt->verify_x509_type == VERIFY_X509_SUBJECT_RDN
- && strcmp(opt->verify_x509_name, common_name) == 0)
- || (opt->verify_x509_type == VERIFY_X509_SUBJECT_RDN_PREFIX
- && strncmp(opt->verify_x509_name, common_name, strlen(opt->verify_x509_name)) == 0))
+ const char *err_fmt = "VERIFY X509NAME ERROR: %s, must be %s";
+ const char *match_str = common_name;
+ bool verified = false;
+ switch (opt->verify_x509_type)
{
- msg(D_HANDSHAKE, "VERIFY X509NAME OK: %s", subject);
+ case VERIFY_X509_SUBJECT_DN:
+ match_str = subject;
+ verified = !strcmp(opt->verify_x509_name, match_str);
+ break;
+ case VERIFY_X509_SUBJECT_RDN:
+ verified = !strcmp(opt->verify_x509_name, match_str);
+ break;
+ case VERIFY_X509_SUBJECT_RDN_PREFIX:
+ err_fmt = "VERIFY X509NAME ERROR: %s, must start with %s";
+ verified = !strncmp(opt->verify_x509_name, match_str, strlen(opt->verify_x509_name));
+ break;
+ default:
+ ASSERT(0); /* should not happen */
+ break;
}
- else
+ if (!verified)
{
- msg(D_HANDSHAKE, "VERIFY X509NAME ERROR: %s, must be %s", subject,
- opt->verify_x509_name);
- return FAILURE; /* Reject connection */
+ msg(D_HANDSHAKE, err_fmt, match_str, opt->verify_x509_name);
+ return FAILURE;
}
+ msg(D_HANDSHAKE, "VERIFY X509NAME OK: %s", subject);
}
return SUCCESS;
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1624?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6e7947ab81cf229f0d27714dd563a07ace6bd38a
Gerrit-Change-Number: 1624
Gerrit-PatchSet: 1
Gerrit-Owner: selvanair <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel