@@ -14307,19 +14307,17 @@ int CopyDecodedToX509(WOLFSSL_X509* x509, DecodedCert* dCert)
1430714307 /* if der contains original source buffer then store for potential
1430814308 * retrieval */
1430914309 if (dCert->source != NULL && dCert->maxIdx > 0) {
14310- word32 derCertSz = dCert->maxIdx;
14311- #ifdef WOLFSSL_CERT_REJECT_TRAILING
1431214310 /* Store only the certificate itself, bounded by the end of its outer
1431314311 * SEQUENCE (dCert->srcIdx), never any trailing bytes that may follow in
1431414312 * the source buffer. This keeps wolfSSL_i2d_X509 / wolfSSL_X509_get_der
1431514313 * / wolfSSL_X509_digest canonical - they operate on derCert - even on
1431614314 * builds/paths that do not reject trailing data (e.g.
1431714315 * WOLFSSL_NO_ASN_STRICT). It removes only bytes after the certificate,
1431814316 * so the signed certificate bytes are preserved verbatim. */
14317+ word32 derCertSz = dCert->maxIdx;
1431914318 if ((dCert->srcIdx > 0) && (dCert->srcIdx < derCertSz)) {
1432014319 derCertSz = dCert->srcIdx;
1432114320 }
14322- #endif
1432314321 if (AllocDer(&x509->derCert, derCertSz, CERT_TYPE, x509->heap) == 0) {
1432414322 XMEMCPY(x509->derCert->buffer, dCert->source, derCertSz);
1432514323 }
@@ -14657,14 +14655,12 @@ int CopyDecodedAcertToX509(WOLFSSL_X509_ACERT* x509, DecodedAcert* dAcert)
1465714655 /* if der contains original source buffer then store for potential
1465814656 * retrieval */
1465914657 if (dAcert->source != NULL && dAcert->maxIdx > 0) {
14660- word32 derCertSz = dAcert->maxIdx;
14661- #ifdef WOLFSSL_CERT_REJECT_TRAILING
1466214658 /* Bound to the end of the attribute certificate's outer SEQUENCE so no
1466314659 * trailing bytes after it are ever re-emitted by i2d / get_der. */
14660+ word32 derCertSz = dAcert->maxIdx;
1466414661 if ((dAcert->srcIdx > 0) && (dAcert->srcIdx < derCertSz)) {
1466514662 derCertSz = dAcert->srcIdx;
1466614663 }
14667- #endif
1466814664 if (AllocDer(&x509->derCert, derCertSz, CERT_TYPE, x509->heap) == 0) {
1466914665 XMEMCPY(x509->derCert->buffer, dAcert->source, derCertSz);
1467014666 }
0 commit comments