Skip to content

Commit

Permalink
(xmlsec-mscng,xmsec-mscrypto,xmlsec-gnutls) Improve certificates veri…
Browse files Browse the repository at this point in the history
…fication (#822)
  • Loading branch information
lsh123 authored Jul 18, 2024
1 parent f68e012 commit f15b0cb
Show file tree
Hide file tree
Showing 22 changed files with 543 additions and 187 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/make-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- xmlsec-1_2_x

jobs:
check-ubuntu-openssl300:
check-ubuntu:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
run: |
make check
check-ubuntu-openssl110:
check-ubuntu-openssl-111:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
Expand Down
73 changes: 45 additions & 28 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,42 +67,59 @@ <h1>XML Security Library</h1>
see the Copyright file in the distribution for details.<br><br></p>
<p><b>News</b></p>
<ul>
<li>July 11 2024<br>
<li>
TBD<br>
The <a href="download.html">XML Security Library 1.2.41</a> release includes the following changes:
<ul>
<li>(xmlsec-mscng,xmlsec-mscrypto) Improved certificates verification.</li>
<li>(xmlsec-gnutls) Added support for self-signed certificates.</li>
<li>Several other small fixes (see <a href="https://github.com/lsh123/xmlsec/commits/master">more details</a>).</li>
</ul>
</li>
<br>

<li>
July 11 2024<br>
The <a href="download.html">XML Security Library 1.2.40</a> release includes the following changes:
<ul>
<li>(xmlsec-core) Fixed functions deprecated in LibXML2 2.13.1 (including disabling HTTP support by default).</li>
<li>(xmlsec-nss) Increased keys size in all tests to support NSS 3.101.</li>
<li>(windows) Added "ftp" and "http" flags in 'configure.js' (both are disabled by default).</li>
<li>Several other small fixes (<a href="https://github.com/lsh123/xmlsec/commits/xmlsec-1_2_x">more details</a>).</li>
</ul>
</li>
<br>
<li>December 12 2023<br>
The <a href="download.html">XML Security Library 1.2.39</a> release includes the following changes:
<ul>
<li>Added options to enable/disable local files, HTTP, and FTP support. FTP is disabled by default.</li>
<li>Several other small fixes (<a href="https://github.com/lsh123/xmlsec/commits/xmlsec-1_2_x">more details</a>).</li>
<li>(xmlsec-core) Fixed functions deprecated in LibXML2 2.13.1 (including disabling HTTP support by default).</li>
<li>(xmlsec-nss) Increased keys size in all tests to support NSS 3.101.</li>
<li>(windows) Added "ftp" and "http" flags in 'configure.js' (both are disabled by default).</li>
<li>Several other small fixes (<a href="https://github.com/lsh123/xmlsec/commits/xmlsec-1_2_x">more details</a>).</li>
</ul>
</li>
<br>
<li>
December 12 2023<br>
The <a href="download.html">XML Security Library 1.2.39</a> release includes the following changes:
<ul>
<li>Added options to enable/disable local files, HTTP, and FTP support. FTP is disabled by default.</li>
<li>Several other small fixes (<a href="https://github.com/lsh123/xmlsec/commits/xmlsec-1_2_x">more details</a>).</li>
</ul>
</li>
<br>
<li>July 5 2023<br>
The <a href="download.html">XML Security Library 1.2.38</a> release includes the following changes:
</li>
<br>
<li>
July 5 2023<br>
The <a href="download.html">XML Security Library 1.2.38</a> release includes the following changes:
<ul>
<li>Fixed static linking with MinGW.</li>
<li>(xmlsec-mscng) Fixed block ciphers key size.</li>
<li>Several other small fixes (<a href="https://github.com/lsh123/xmlsec/commits/xmlsec-1_2_x">more details</a>).</li>
<li>Fixed static linking with MinGW.</li>
<li>(xmlsec-mscng) Fixed block ciphers key size.</li>
<li>Several other small fixes (<a href="https://github.com/lsh123/xmlsec/commits/xmlsec-1_2_x">more details</a>).</li>
</ul>
</li>
<br>
<li>November 30 2022<br>
</li>
<br>
<li>
November 30 2022<br>
The <a href="download.html">XML Security Library 1.2.37</a> release includes the following changes:
<ul>
<li>Fixed two regressions from 1.2.36 release: <a href="https://github.com/lsh123/xmlsec/issues/437">issue #437</a>
and <a href="https://github.com/lsh123/xmlsec/issues/449">issue #449</a>.</li>
<li>
Fixed two regressions from 1.2.36 release: <a href="https://github.com/lsh123/xmlsec/issues/437">issue #437</a>
and <a href="https://github.com/lsh123/xmlsec/issues/449">issue #449</a>.
</li>
</ul>
</li>
<br>
<li>See <a href="news.html">News page</a> for older announcements.</li>
</li>
<br>
<li>See <a href="news.html">News page</a> for older announcements.</li>
</ul>
</td></tr></table></td>
</tr></table></body>
Expand Down
7 changes: 7 additions & 0 deletions include/xmlsec/errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,13 @@ extern "C" {
*/
#define XMLSEC_ERRORS_R_CERT_HAS_EXPIRED 76

/**
* XMLSEC_ERRORS_R_CRL_VERIFY_FAILED:
*
* CRL verification failed.
*/
#define XMLSEC_ERRORS_R_CRL_VERIFY_FAILED 77

/**
* XMLSEC_ERRORS_R_DSIG_NO_REFERENCES:
*
Expand Down
11 changes: 11 additions & 0 deletions src/gnutls/x509utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,17 @@ xmlSecGnuTLSX509CertDup(gnutls_x509_crt_t src) {
return (res);
}


/* returns 1 if self signed; 0 - if not; <0 on error*/
int
xmlSecGnuTLSX509CertIsSelfSigned(gnutls_x509_crt_t cert) {
unsigned ret;

xmlSecAssert2(cert != NULL, -1);
ret = gnutls_x509_crt_check_issuer(cert, cert);
return ((ret != 0) ? 1 : 0);
}

xmlChar *
xmlSecGnuTLSX509CertGetSubjectDN(gnutls_x509_crt_t cert) {
char* buf = NULL;
Expand Down
1 change: 1 addition & 0 deletions src/gnutls/x509utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ xmlSecPtrListId xmlSecGnuTLSX509CrlListGetKlass (void);
*
************************************************************************/
gnutls_x509_crt_t xmlSecGnuTLSX509CertDup (gnutls_x509_crt_t src);
int xmlSecGnuTLSX509CertIsSelfSigned (gnutls_x509_crt_t cert);
xmlChar * xmlSecGnuTLSX509CertGetSubjectDN (gnutls_x509_crt_t cert);
xmlChar * xmlSecGnuTLSX509CertGetIssuerDN (gnutls_x509_crt_t cert);
xmlChar * xmlSecGnuTLSX509CertGetIssuerSerial (gnutls_x509_crt_t cert);
Expand Down
47 changes: 28 additions & 19 deletions src/gnutls/x509vfy.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,27 +364,36 @@ xmlSecGnuTLSX509StoreVerify(xmlSecKeyDataStorePtr store,
goto done;
}

/* check if we are the "leaf" node in the certs chain */
if(xmlSecGnuTLSX509FindSignedCert(certs, cert) != NULL) {
continue;
}

/* build the chain */
for(cert2 = cert, cert_list_cur_size = 0;
(cert2 != NULL) && (cert_list_cur_size < cert_list_size);
++cert_list_cur_size)
{
gnutls_x509_crt_t tmp;

/* store */
cert_list[cert_list_cur_size] = cert2;
if (xmlSecGnuTLSX509CertIsSelfSigned(cert) != 1) {
/* check if we are the "leaf" node in the certs chain */
if (xmlSecGnuTLSX509FindSignedCert(certs, cert) != NULL) {
continue;
}

/* find next */
tmp = xmlSecGnuTLSX509FindSignerCert(certs, cert2);
if(tmp == NULL) {
tmp = xmlSecGnuTLSX509FindSignerCert(&(ctx->certsUntrusted), cert2);
/* build the chain */
for (cert2 = cert, cert_list_cur_size = 0;
(cert2 != NULL) && (cert_list_cur_size < cert_list_size);
++cert_list_cur_size)
{
gnutls_x509_crt_t tmp;

/* store */
cert_list[cert_list_cur_size] = cert2;

/* find next */
tmp = xmlSecGnuTLSX509FindSignerCert(certs, cert2);
if (tmp == NULL) {
tmp = xmlSecGnuTLSX509FindSignerCert(&(ctx->certsUntrusted), cert2);
}
cert2 = tmp;
}
cert2 = tmp;
} else if (certs_size == 1) {
/* only do self signed cert when it is the only cert */
/* chain for self signed cert is easy */
cert_list[0] = cert;
cert_list_cur_size = 1;
} else {
continue;
}

/* try to verify */
Expand Down
2 changes: 1 addition & 1 deletion src/mscng/certkeys.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ xmlSecMSCngKeyDataCertGetPubkey(PCCERT_CONTEXT cert, BCRYPT_KEY_HANDLE* key) {
xmlSecAssert2(key != NULL, -1);

if(!CryptImportPublicKeyInfoEx2(X509_ASN_ENCODING,
&cert->pCertInfo->SubjectPublicKeyInfo,
&(cert->pCertInfo->SubjectPublicKeyInfo),
0,
NULL,
key)) {
Expand Down
Loading

0 comments on commit f15b0cb

Please sign in to comment.