Attention is currently required from: Arne Schwabe.
Hello Arne Schwabe,
I'd like you to do a code review.
Please visit
https://gerrit.openvpn.net/c/openvpn/+/2353?usp=email
to review the following change.
Change subject: pkcs11: remove duplicated branches and a redundant check
......................................................................
pkcs11: remove duplicated branches and a redundant check
- Merge the PKCS11H_LOG_ERROR case into default and drop the M_FATAL
branch, both of which matched the fallback.
- In tls_ctx_use_pkcs11(), choose the id string first and deserialize
it once; set certificate to NULL once after pkcs11_init_tls_session().
- Drop the always-true rv == CKR_OK test in show_pkcs11_ids().
Change-Id: I26814847219a10bd0f311123ba44467b42e725e1
Signed-off-by: Razvan Cojocaru <[email protected]>
---
M src/openvpn/pkcs11.c
1 file changed, 10 insertions(+), 31 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/53/2353/1
diff --git a/src/openvpn/pkcs11.c b/src/openvpn/pkcs11.c
index 3610224..a2c9d2f 100644
--- a/src/openvpn/pkcs11.c
+++ b/src/openvpn/pkcs11.c
@@ -109,9 +109,6 @@
break;
case PKCS11H_LOG_ERROR:
- openvpn_flags = M_FATAL;
- break;
-
default:
openvpn_flags = M_FATAL;
break;
@@ -145,10 +142,6 @@
{
pkcs11_flags = PKCS11H_LOG_WARN;
}
- else if ((flags & M_FATAL) != 0)
- {
- pkcs11_flags = PKCS11H_LOG_ERROR;
- }
else
{
pkcs11_flags = PKCS11H_LOG_ERROR;
@@ -589,10 +582,11 @@
"PKCS#11: tls_ctx_use_pkcs11 - entered - ssl_ctx=%p,
pkcs11_id_management=%d, pkcs11_id='%s'",
(void *)ssl_ctx, pkcs11_id_management ? 1 : 0, pkcs11_id);
+ struct user_pass id_resp;
+ const char *id = pkcs11_id;
+
if (pkcs11_id_management)
{
- struct user_pass id_resp;
-
CLEAR(id_resp);
id_resp.defined = false;
@@ -606,21 +600,13 @@
goto cleanup;
}
- if ((rv =
pkcs11h_certificate_deserializeCertificateId(&certificate_id, id_resp.password))
- != CKR_OK)
- {
- msg(M_WARN, "PKCS#11: Cannot deserialize id %ld-'%s'", rv,
pkcs11h_getMessage(rv));
- goto cleanup;
- }
+ id = id_resp.password;
}
- else
+
+ if ((rv = pkcs11h_certificate_deserializeCertificateId(&certificate_id,
id)) != CKR_OK)
{
- if ((rv =
pkcs11h_certificate_deserializeCertificateId(&certificate_id, pkcs11_id))
- != CKR_OK)
- {
- msg(M_WARN, "PKCS#11: Cannot deserialize id %ld-'%s'", rv,
pkcs11h_getMessage(rv));
- goto cleanup;
- }
+ msg(M_WARN, "PKCS#11: Cannot deserialize id %ld-'%s'", rv,
pkcs11h_getMessage(rv));
+ goto cleanup;
}
if ((rv = pkcs11h_certificate_create(certificate_id, NULL,
PKCS11H_PROMPT_MASK_ALLOW_ALL,
@@ -631,16 +617,9 @@
goto cleanup;
}
- if ((pkcs11_init_tls_session(certificate, ssl_ctx)))
- {
- /* Handled by SSL context free */
- certificate = NULL;
- goto cleanup;
- }
-
+ ok = !pkcs11_init_tls_session(certificate, ssl_ctx);
/* Handled by SSL context free */
certificate = NULL;
- ok = true;
cleanup:
if (certificate != NULL)
@@ -764,7 +743,7 @@
goto cleanup1;
}
- if (rv == CKR_OK && (ser = (char *)malloc(ser_len)) == NULL)
+ if ((ser = (char *)malloc(ser_len)) == NULL)
{
msg(M_FATAL, "PKCS#11: Cannot allocate memory");
goto cleanup1;
--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2353?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I26814847219a10bd0f311123ba44467b42e725e1
Gerrit-Change-Number: 2353
Gerrit-PatchSet: 1
Gerrit-Owner: Răzvan Cojocaru <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Arne Schwabe <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel