@@ -16757,6 +16757,36 @@ int ProcessPeerCerts(WOLFSSL* ssl, byte* input, word32* inOutIdx,
1675716757 if (ssl->peerVerifyRet == 0) /* Return first cert error here */
1675816758 ssl->peerVerifyRet = WOLFSSL_X509_V_OK;
1675916759 #endif
16760+
16761+ #if defined(HAVE_RPK) && (defined(OPENSSL_EXTRA) || \
16762+ defined(OPENSSL_EXTRA_X509_SMALL))
16763+ /* A Raw Public Key cert (RFC 7250) has no issuer and no
16764+ * signature, so ParseCertRelative performed no peer
16765+ * authentication. Unless an out-of-band trust mechanism
16766+ * (DANE, key pinning, etc.) has bound this key, report the
16767+ * peer as unauthenticated through wolfSSL_get_verify_result()
16768+ * rather than leaving it at WOLFSSL_X509_V_OK. The handshake
16769+ * is intentionally not failed here: per RFC 7250 the
16770+ * application is responsible for validating the key out of
16771+ * band. Applies to both peers - client checking the
16772+ * server's RPK and server checking the client's RPK.
16773+ * WOLFSSL_VERIFY_NONE leaves the result untouched. */
16774+ if (args->dCert->isRPK && !ssl->options.verifyNone) {
16775+ int rpkTrusted = 0;
16776+ #if defined(HAVE_DANE)
16777+ if (ssl->options.useDANE) {
16778+ /* DANE authentication should be added; set
16779+ * rpkTrusted = 1 on a successful match. */
16780+ }
16781+ #endif /* HAVE_DANE */
16782+ if (!rpkTrusted &&
16783+ ssl->peerVerifyRet == WOLFSSL_X509_V_OK) {
16784+ ssl->peerVerifyRet = (unsigned long)
16785+ WOLFSSL_X509_V_ERR_RPK_UNTRUSTED;
16786+ }
16787+ }
16788+ #endif /* HAVE_RPK && (OPENSSL_EXTRA || OPENSSL_EXTRA_X509_SMALL) */
16789+
1676016790 #if defined(SESSION_CERTS) && defined(WOLFSSL_ALT_CERT_CHAINS)
1676116791 /* if using alternate chain, store the cert used */
1676216792 if (ssl->options.usingAltCertChain) {
@@ -16775,17 +16805,10 @@ int ProcessPeerCerts(WOLFSSL* ssl, byte* input, word32* inOutIdx,
1677516805 if (ssl->options.side == WOLFSSL_SERVER_END) {
1677616806 #if defined(HAVE_RPK)
1677716807 if (args->dCert->isRPK) {
16778- /* to verify Raw Public Key cert, DANE(RFC6698)
16779- * should be introduced. Without DANE, no
16780- * authentication is performed.
16781- */
16782- #if defined(HAVE_DANE)
16783- if (ssl->useDANE) {
16784- /* DANE authentication should be added */
16785- }
16786- #endif /* HAVE_DANE */
16808+ /* RPK certs carry no X.509 version; the RPK trust
16809+ * check above already handled this cert. */
1678716810 }
16788- else /* skip followingx509 version check */
16811+ else /* skip following x509 version check */
1678916812 #endif /* HAVE_RPK */
1679016813 if (args->dCert->version != WOLFSSL_X509_V3) {
1679116814 WOLFSSL_MSG("Peers certificate was not version 3!");
@@ -27474,6 +27497,9 @@ static const char* wolfSSL_ERR_reason_error_string_OpenSSL(unsigned long e)
2747427497 case WOLFSSL_X509_V_ERR_IP_ADDRESS_MISMATCH:
2747527498 return "IP address mismatch";
2747627499
27500+ case WOLFSSL_X509_V_ERR_RPK_UNTRUSTED:
27501+ return "raw public key not trusted";
27502+
2747727503 default:
2747827504 return NULL;
2747927505 }
0 commit comments