]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
certificates: Use shared destructor for x509_cdp_t
authorTobias Brunner <tobias@strongswan.org>
Thu, 7 Sep 2017 09:45:23 +0000 (11:45 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 18 Sep 2017 08:54:19 +0000 (10:54 +0200)
src/libstrongswan/credentials/certificates/x509.c
src/libstrongswan/credentials/certificates/x509.h
src/libstrongswan/plugins/openssl/openssl_x509.c
src/libstrongswan/plugins/x509/x509_cert.c
src/libstrongswan/plugins/x509/x509_crl.c
src/pki/commands/signcrl.c

index 5eefa0bb4e7fda97603d91e78cd8676cf8598492..d39ba199739faf7a6ddc31ce46a39d12633c0635 100644 (file)
@@ -25,3 +25,12 @@ ENUM_NEXT(x509_flag_names, X509_ANY, X509_ANY, X509_OCSP_SIGNER,
        "ANY");
 ENUM_END(x509_flag_names, X509_ANY);
 
+/*
+ * Described in header
+ */
+void x509_cdp_destroy(x509_cdp_t *this)
+{
+       free(this->uri);
+       DESTROY_IF(this->issuer);
+       free(this);
+}
index 601c034ef234ac7b429ce5405cce4738b09cbeec..2c640e2da38f24e453e4308572148d371a246148 100644 (file)
@@ -210,8 +210,11 @@ struct x509_t {
         * @return                      enumerator over x509_policy_mapping
         */
        enumerator_t* (*create_policy_mapping_enumerator)(x509_t *this);
-
-
 };
 
+/**
+ * Destroy an x509_cdp_t instance.
+ */
+void x509_cdp_destroy(x509_cdp_t *this);
+
 #endif /** X509_H_ @}*/
index e03a4255d7b0ca4abf35c47d839e3acddd188cae..c04dbfaba63b525526d5b7c948b1dd733d7b15c1 100644 (file)
@@ -188,16 +188,6 @@ struct private_openssl_x509_t {
        refcount_t ref;
 };
 
-/**
- * Destroy a CRL URI struct
- */
-static void crl_uri_destroy(x509_cdp_t *this)
-{
-       free(this->uri);
-       DESTROY_IF(this->issuer);
-       free(this);
-}
-
 /**
  * Convert a GeneralName to an identification_t.
  */
@@ -549,7 +539,8 @@ METHOD(certificate_t, destroy, void,
                                                                                offsetof(identification_t, destroy));
                this->issuerAltNames->destroy_offset(this->issuerAltNames,
                                                                                offsetof(identification_t, destroy));
-               this->crl_uris->destroy_function(this->crl_uris, (void*)crl_uri_destroy);
+               this->crl_uris->destroy_function(this->crl_uris,
+                                                                                (void*)x509_cdp_destroy);
                this->ocsp_uris->destroy_function(this->ocsp_uris, free);
                this->ipAddrBlocks->destroy_offset(this->ipAddrBlocks,
                                                                                offsetof(traffic_selector_t, destroy));
index 974e687f9f7248534cec7e2363ba50064beb2a6b..dea2c704175930633aff6b915a3de379d62b2a4b 100644 (file)
@@ -240,16 +240,6 @@ static bool gn_to_string(identification_t *id, char **uri)
        return len > 0;
 }
 
-/**
- * Destroy a CertificateDistributionPoint
- */
-static void crl_uri_destroy(x509_cdp_t *this)
-{
-       free(this->uri);
-       DESTROY_IF(this->issuer);
-       free(this);
-}
-
 /**
  * Destroy a CertificatePolicy
  */
@@ -1920,7 +1910,8 @@ METHOD(certificate_t, destroy, void,
        {
                this->subjectAltNames->destroy_offset(this->subjectAltNames,
                                                                        offsetof(identification_t, destroy));
-               this->crl_uris->destroy_function(this->crl_uris, (void*)crl_uri_destroy);
+               this->crl_uris->destroy_function(this->crl_uris,
+                                                                                (void*)x509_cdp_destroy);
                this->ocsp_uris->destroy_function(this->ocsp_uris, free);
                this->ipAddrBlocks->destroy_offset(this->ipAddrBlocks,
                                                                                offsetof(traffic_selector_t, destroy));
index d8913ad730d91f9899d20a743cfdc07fb93e7aca..6d18ea544c65ce61815dad127180e71ba3f321d8 100644 (file)
@@ -585,23 +585,14 @@ static void revoked_destroy(revoked_t *revoked)
        free(revoked);
 }
 
-/**
- * Destroy a CDP entry
- */
-static void cdp_destroy(x509_cdp_t *this)
-{
-       free(this->uri);
-       DESTROY_IF(this->issuer);
-       free(this);
-}
-
 METHOD(certificate_t, destroy, void,
        private_x509_crl_t *this)
 {
        if (ref_put(&this->ref))
        {
                this->revoked->destroy_function(this->revoked, (void*)revoked_destroy);
-               this->crl_uris->destroy_function(this->crl_uris, (void*)cdp_destroy);
+               this->crl_uris->destroy_function(this->crl_uris,
+                                                                                (void*)x509_cdp_destroy);
                DESTROY_IF(this->issuer);
                free(this->authKeyIdentifier.ptr);
                free(this->encoding.ptr);
index 25a3aac52f80d1a20dbbd8416a7004b207c21fa8..4c2e6df714ab744db5105191b31a8203863d6173 100644 (file)
@@ -108,15 +108,6 @@ static int read_serial(char *file, char *buf, int buflen)
        return serial.len;
 }
 
-/**
- * Destroy a CDP
- */
-static void cdp_destroy(x509_cdp_t *this)
-{
-       free(this->uri);
-       free(this);
-}
-
 /**
  * Sign a CRL
  */
@@ -439,7 +430,7 @@ error:
        free(encoding.ptr);
        free(baseCrlNumber.ptr);
        list->destroy_function(list, (void*)revoked_destroy);
-       cdps->destroy_function(cdps, (void*)cdp_destroy);
+       cdps->destroy_function(cdps, (void*)x509_cdp_destroy);
        if (error)
        {
                fprintf(stderr, "%s\n", error);
@@ -449,7 +440,7 @@ error:
 
 usage:
        list->destroy_function(list, (void*)revoked_destroy);
-       cdps->destroy_function(cdps, (void*)cdp_destroy);
+       cdps->destroy_function(cdps, (void*)x509_cdp_destroy);
        return command_usage(error);
 }