Skip to content

Instantly share code, notes, and snippets.

@a60814billy
Last active September 11, 2021 20:10
Show Gist options
  • Save a60814billy/6ae6ab577ea1f06926394533bf65fdc4 to your computer and use it in GitHub Desktop.
Save a60814billy/6ae6ab577ea1f06926394533bf65fdc4 to your computer and use it in GitHub Desktop.
Add CDP extension in security_file_certgen. (based on squid-4.13.tar.gz)
--- squid-4.13/src/ssl/gadgets.cc 2020-08-23 02:37:05.000000000 +0800
+++ squid-4.13-modify/src/ssl/gadgets.cc 2021-09-12 04:02:25.362198387 +0800
@@ -544,6 +544,18 @@
return true;
}
+void add_ext(X509* cert)
+{
+ X509_EXTENSION *ex;
+ X509V3_CTX ctx;
+ X509V3_set_ctx_nodb(&ctx);
+ X509V3_set_ctx(&ctx, cert, cert, NULL, NULL, 0);
+ ex = X509V3_EXT_conf_nid(NULL, &ctx, NID_crl_distribution_points, "URI:http://crl.cacert.org/revoke.crl");
+ if (!ex) return;
+ X509_add_ext(cert, ex, -1);
+ X509_EXTENSION_free(ex);
+}
+
static bool generateFakeSslCertificate(Security::CertPointer & certToStore, Security::PrivateKeyPointer & pkeyToStore, Ssl::CertificateProperties const &properties, Ssl::BIGNUM_Pointer const &serial)
{
Security::PrivateKeyPointer pkey;
@@ -579,6 +591,8 @@
if (!ret)
return false;
+ add_ext(cert.get());
+
const EVP_MD *hash = properties.signHash ? properties.signHash : EVP_get_digestbyname(SQUID_SSL_SIGN_HASH_IF_NONE);
assert(hash);
/*Now sign the request */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment