Skip to content

Commit

Permalink
Merge pull request wolfSSL#572 from JacobBarthelmeh/print
Browse files Browse the repository at this point in the history
  • Loading branch information
ejohnstown authored Sep 7, 2023
2 parents dd7c17a + 57519c6 commit eb7d053
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions examples/client/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,25 +382,26 @@ int ClientPublicKeyCheck(const byte* pubKey, word32 pubKeySz, void* ctx)
if (ParseRFC6187(pubKey, pubKeySz, &der, &derSz) == WS_SUCCESS) {
wc_InitDecodedCert(&dCert, der, derSz, NULL);
if (wc_ParseCert(&dCert, CERT_TYPE, NO_VERIFY, NULL) != 0) {
printf("public key not a cert\n");
WLOG(WS_LOG_DEBUG, "public key not a cert");
}
else {
int ipMatch = 0;
DNS_entry* current = dCert.altNames;

if (ctx == NULL) {
fprintf(stderr, "No host IP set to check against!\n");
WLOG(WS_LOG_ERROR, "No host IP set to check against!");
ret = -1;
}

if (ret == 0) {
while (current != NULL) {
if (current->type == ASN_IP_TYPE) {
printf("host cert alt. name IP : %s\n",
WLOG(WS_LOG_DEBUG, "host cert alt. name IP : %s",
current->ipString);
printf("\texpecting host IP : %s\n", (char*)ctx);
WLOG(WS_LOG_DEBUG,
"\texpecting host IP : %s", (char*)ctx);
if (XSTRCMP(ctx, current->ipString) == 0) {
printf("\tmatched!\n");
WLOG(WS_LOG_DEBUG, "\tmatched!");
ipMatch = 1;
}
}
Expand All @@ -424,8 +425,8 @@ int ClientPublicKeyCheck(const byte* pubKey, word32 pubKeySz, void* ctx)
}
}
#else
printf("wolfSSL not built with OPENSSL_ALL or WOLFSSL_IP_ALT_NAME\n");
printf("\tnot checking IP address from peer's cert\n");
WLOG(WS_LOG_DEBUG, "wolfSSL not built with OPENSSL_ALL or WOLFSSL_IP_ALT_NAME");
WLOG(WS_LOG_DEBUG, "\tnot checking IP address from peer's cert");
#endif
#endif

Expand Down

0 comments on commit eb7d053

Please sign in to comment.