X509_dup.3ossl - Man Page

ASN1 object utilities

Synopsis

 #include <openssl/asn1t.h>

 DECLARE_ASN1_FUNCTIONS(type)
 IMPLEMENT_ASN1_FUNCTIONS(stname)

 typedef struct ASN1_ITEM_st ASN1_ITEM;

 extern const ASN1_ITEM TYPE_it;
 TYPE *TYPE_new(void);
 TYPE *TYPE_dup(const TYPE *a);
 void TYPE_free(TYPE *a);
 int TYPE_print_ctx(BIO *out, TYPE *a, int indent, const ASN1_PCTX *pctx);

The following functions have been deprecated since OpenSSL 3.0, and can be hidden entirely by defining OPENSSL_API_COMPAT with a suitable version value, see openssl_user_macros(7):

 DSA *DSAparams_dup(const DSA *dsa);
 RSA *RSAPrivateKey_dup(const RSA *rsa);
 RSA *RSAPublicKey_dup(const RSA *rsa);

Description

In the description below, TYPE is used as a placeholder for any of the OpenSSL datatypes, such as X509.

The OpenSSL ASN1 parsing library templates are like a data-driven bytecode interpreter. Every ASN1 object as a global variable, TYPE_it, that describes the item such as its fields.  (On systems which cannot export variables from shared libraries, the global is instead a function which returns a pointer to a static variable.

The macro DECLARE_ASN1_FUNCTIONS() is typically used in header files to generate the function declarations.

The macro IMPLEMENT_ASN1_FUNCTIONS() is used once in a source file to generate the function bodies.

TYPE_new() allocates an empty object of the indicated type. The object returned must be released by calling TYPE_free().

TYPE_new_ex() is similar to TYPE_new() but also passes the library context libctx and the property query propq to use when retrieving algorithms from providers. This created object can then be used when loading binary data using d2i_TYPE().

TYPE_dup() copies an existing object, leaving it untouched. Note, however, that the internal representation of the object may contain (besides the ASN.1 structure) further data, which is not copied. For instance, an X509 object usually is augmented by cached information on X.509v3 extensions, etc., and losing it can lead to wrong validation results. To avoid such situations, better use TYPE_up_ref() if available. For the case of X509 objects, an alternative to using X509_up_ref(3) may be to still call TYPE_dup(), e.g., copied_cert = X509_dup(cert), followed by X509_check_purpose(copied_cert, -1, 0), which re-builds the cached data.

TYPE_free() releases the object and all pointers and sub-objects within it.

TYPE_print_ctx() prints the object a on the specified BIO out. Each line will be prefixed with indent spaces. The pctx specifies the printing context and is for internal use; use NULL to get the default behavior.  If a print function is user-defined, then pass in any pctx down to any nested calls.

Return Values

TYPE_new(), TYPE_new_ex() and TYPE_dup() return a pointer to the object or NULL on failure.

TYPE_print_ctx() returns 1 on success or zero on failure.

See Also

X509_up_ref(3)

History

The functions X509_REQ_new_ex(), X509_CRL_new_ex(), PKCS7_new_ex() and CMS_ContentInfo_new_ex() were added in OpenSSL 3.0.

The functions DSAparams_dup(), RSAPrivateKey_dup() and RSAPublicKey_dup() were deprecated in 3.0.

Referenced By

ADMISSIONS.3ossl(3).

The man pages ACCESS_DESCRIPTION_free.3ossl(3), ACCESS_DESCRIPTION_new.3ossl(3), ADMISSIONS_free.3ossl(3), ADMISSIONS_new.3ossl(3), ADMISSION_SYNTAX_free.3ossl(3), ADMISSION_SYNTAX_new.3ossl(3), ASIdentifierChoice_free.3ossl(3), ASIdentifierChoice_new.3ossl(3), ASIdentifiers_free.3ossl(3), ASIdentifiers_new.3ossl(3), ASIdOrRange_free.3ossl(3), ASIdOrRange_new.3ossl(3), ASN1_ITEM.3ossl(3), ASRange_free.3ossl(3), ASRange_new.3ossl(3), AUTHORITY_INFO_ACCESS_free.3ossl(3), AUTHORITY_INFO_ACCESS_new.3ossl(3), AUTHORITY_KEYID_free.3ossl(3), AUTHORITY_KEYID_new.3ossl(3), BASIC_CONSTRAINTS_free.3ossl(3), BASIC_CONSTRAINTS_new.3ossl(3), CERTIFICATEPOLICIES_free.3ossl(3), CERTIFICATEPOLICIES_new.3ossl(3), CMS_ContentInfo_free.3ossl(3), CMS_ContentInfo_new.3ossl(3), CMS_ContentInfo_new_ex.3ossl(3), CMS_ContentInfo_print_ctx.3ossl(3), CMS_EnvelopedData_it.3ossl(3), CMS_ReceiptRequest_free.3ossl(3), CMS_ReceiptRequest_new.3ossl(3), CMS_SignedData_free.3ossl(3), CMS_SignedData_new.3ossl(3), CRL_DIST_POINTS_free.3ossl(3), CRL_DIST_POINTS_new.3ossl(3), DECLARE_ASN1_FUNCTIONS.3ossl(3), DIRECTORYSTRING_free.3ossl(3), DIRECTORYSTRING_new.3ossl(3), DISPLAYTEXT_free.3ossl(3), DISPLAYTEXT_new.3ossl(3), DIST_POINT_free.3ossl(3), DIST_POINT_NAME_free.3ossl(3), DIST_POINT_NAME_new.3ossl(3), DIST_POINT_new.3ossl(3), DSAparams_dup.3ossl(3), ECPARAMETERS_free.3ossl(3), ECPARAMETERS_new.3ossl(3), ECPKPARAMETERS_free.3ossl(3), ECPKPARAMETERS_new.3ossl(3), EDIPARTYNAME_free.3ossl(3), EDIPARTYNAME_new.3ossl(3), ESS_CERT_ID_dup.3ossl(3), ESS_CERT_ID_free.3ossl(3), ESS_CERT_ID_new.3ossl(3), ESS_CERT_ID_V2_dup.3ossl(3), ESS_CERT_ID_V2_free.3ossl(3), ESS_CERT_ID_V2_new.3ossl(3), ESS_ISSUER_SERIAL_dup.3ossl(3), ESS_ISSUER_SERIAL_free.3ossl(3), ESS_ISSUER_SERIAL_new.3ossl(3), ESS_SIGNING_CERT_dup.3ossl(3), ESS_SIGNING_CERT_free.3ossl(3), ESS_SIGNING_CERT_it.3ossl(3), ESS_SIGNING_CERT_new.3ossl(3), ESS_SIGNING_CERT_V2_dup.3ossl(3), ESS_SIGNING_CERT_V2_free.3ossl(3), ESS_SIGNING_CERT_V2_it.3ossl(3), ESS_SIGNING_CERT_V2_new.3ossl(3), EXTENDED_KEY_USAGE_free.3ossl(3), EXTENDED_KEY_USAGE_new.3ossl(3), GENERAL_NAME_dup.3ossl(3), GENERAL_NAME_free.3ossl(3), GENERAL_NAME_new.3ossl(3), GENERAL_NAMES_free.3ossl(3), GENERAL_NAMES_new.3ossl(3), GENERAL_SUBTREE_free.3ossl(3), GENERAL_SUBTREE_new.3ossl(3), IMPLEMENT_ASN1_FUNCTIONS.3ossl(3), IPAddressChoice_free.3ossl(3), IPAddressChoice_new.3ossl(3), IPAddressFamily_free.3ossl(3), IPAddressFamily_new.3ossl(3), IPAddressOrRange_free.3ossl(3), IPAddressOrRange_new.3ossl(3), IPAddressRange_free.3ossl(3), IPAddressRange_new.3ossl(3), ISSUER_SIGN_TOOL_free.3ossl(3), ISSUER_SIGN_TOOL_it.3ossl(3), ISSUER_SIGN_TOOL_new.3ossl(3), ISSUING_DIST_POINT_free.3ossl(3), ISSUING_DIST_POINT_it.3ossl(3), ISSUING_DIST_POINT_new.3ossl(3), NAME_CONSTRAINTS_free.3ossl(3), NAME_CONSTRAINTS_new.3ossl(3), NAMING_AUTHORITY_free.3ossl(3), NAMING_AUTHORITY_new.3ossl(3), NETSCAPE_CERT_SEQUENCE_free.3ossl(3), NETSCAPE_CERT_SEQUENCE_new.3ossl(3), NETSCAPE_SPKAC_free.3ossl(3), NETSCAPE_SPKAC_new.3ossl(3), NETSCAPE_SPKI_free.3ossl(3), NETSCAPE_SPKI_new.3ossl(3), NOTICEREF_free.3ossl(3), NOTICEREF_new.3ossl(3), OCSP_BASICRESP_free.3ossl(3), OCSP_BASICRESP_new.3ossl(3), OCSP_CERTID_dup.3ossl(3), OCSP_CERTID_new.3ossl(3), OCSP_CERTSTATUS_free.3ossl(3), OCSP_CERTSTATUS_new.3ossl(3), OCSP_CRLID_free.3ossl(3), OCSP_CRLID_new.3ossl(3), OCSP_ONEREQ_free.3ossl(3), OCSP_ONEREQ_new.3ossl(3), OCSP_REQINFO_free.3ossl(3), OCSP_REQINFO_new.3ossl(3), OCSP_RESPBYTES_free.3ossl(3), OCSP_RESPBYTES_new.3ossl(3), OCSP_RESPDATA_free.3ossl(3), OCSP_RESPDATA_new.3ossl(3), OCSP_RESPID_free.3ossl(3), OCSP_RESPID_new.3ossl(3), OCSP_RESPONSE_new.3ossl(3), OCSP_REVOKEDINFO_free.3ossl(3), OCSP_REVOKEDINFO_new.3ossl(3), OCSP_SERVICELOC_free.3ossl(3), OCSP_SERVICELOC_new.3ossl(3), OCSP_SIGNATURE_free.3ossl(3), OCSP_SIGNATURE_new.3ossl(3), OCSP_SINGLERESP_free.3ossl(3), OCSP_SINGLERESP_new.3ossl(3), OSSL_CMP_ITAV_dup.3ossl(3), OSSL_CMP_ITAV_free.3ossl(3), OSSL_CMP_MSG_dup.3ossl(3), OSSL_CMP_MSG_free.3ossl(3), OSSL_CMP_MSG_it.3ossl(3), OSSL_CMP_PKIHEADER_free.3ossl(3), OSSL_CMP_PKIHEADER_it.3ossl(3), OSSL_CMP_PKIHEADER_new.3ossl(3), OSSL_CMP_PKISI_dup.3ossl(3), OSSL_CMP_PKISI_free.3ossl(3), OSSL_CMP_PKISI_it.3ossl(3), OSSL_CMP_PKISI_new.3ossl(3), OSSL_CMP_PKISTATUS_it.3ossl(3), OSSL_CRMF_CERTID_dup.3ossl(3), OSSL_CRMF_CERTID_free.3ossl(3), OSSL_CRMF_CERTID_it.3ossl(3), OSSL_CRMF_CERTID_new.3ossl(3), OSSL_CRMF_CERTTEMPLATE_free.3ossl(3), OSSL_CRMF_CERTTEMPLATE_it.3ossl(3), OSSL_CRMF_CERTTEMPLATE_new.3ossl(3), OSSL_CRMF_ENCRYPTEDVALUE_free.3ossl(3), OSSL_CRMF_ENCRYPTEDVALUE_it.3ossl(3), OSSL_CRMF_ENCRYPTEDVALUE_new.3ossl(3), OSSL_CRMF_MSG_dup.3ossl(3), OSSL_CRMF_MSG_free.3ossl(3), OSSL_CRMF_MSG_it.3ossl(3), OSSL_CRMF_MSG_new.3ossl(3), OSSL_CRMF_MSGS_free.3ossl(3), OSSL_CRMF_MSGS_it.3ossl(3), OSSL_CRMF_MSGS_new.3ossl(3), OSSL_CRMF_PBMPARAMETER_free.3ossl(3), OSSL_CRMF_PBMPARAMETER_it.3ossl(3), OSSL_CRMF_PBMPARAMETER_new.3ossl(3), OSSL_CRMF_PKIPUBLICATIONINFO_free.3ossl(3), OSSL_CRMF_PKIPUBLICATIONINFO_it.3ossl(3), OSSL_CRMF_PKIPUBLICATIONINFO_new.3ossl(3), OSSL_CRMF_SINGLEPUBINFO_free.3ossl(3), OSSL_CRMF_SINGLEPUBINFO_it.3ossl(3), OSSL_CRMF_SINGLEPUBINFO_new.3ossl(3), OTHERNAME_free.3ossl(3), OTHERNAME_new.3ossl(3), PBE2PARAM_free.3ossl(3), PBE2PARAM_new.3ossl(3), PBEPARAM_free.3ossl(3), PBEPARAM_new.3ossl(3), PBKDF2PARAM_free.3ossl(3), PBKDF2PARAM_new.3ossl(3), PBMAC1PARAM_free.3ossl(3), PBMAC1PARAM_it.3ossl(3), PBMAC1PARAM_new.3ossl(3), PKCS12_BAGS_free.3ossl(3), PKCS12_BAGS_new.3ossl(3), PKCS12_free.3ossl(3), PKCS12_MAC_DATA_free.3ossl(3), PKCS12_MAC_DATA_new.3ossl(3), PKCS12_new.3ossl(3), PKCS12_SAFEBAG_free.3ossl(3), PKCS12_SAFEBAG_new.3ossl(3), PKCS7_DIGEST_free.3ossl(3), PKCS7_DIGEST_new.3ossl(3), PKCS7_dup.3ossl(3), PKCS7_ENC_CONTENT_free.3ossl(3), PKCS7_ENC_CONTENT_new.3ossl(3), PKCS7_ENCRYPT_free.3ossl(3), PKCS7_ENCRYPT_new.3ossl(3), PKCS7_ENVELOPE_free.3ossl(3), PKCS7_ENVELOPE_new.3ossl(3), PKCS7_free.3ossl(3), PKCS7_ISSUER_AND_SERIAL_free.3ossl(3), PKCS7_ISSUER_AND_SERIAL_new.3ossl(3), PKCS7_new.3ossl(3), PKCS7_new_ex.3ossl(3), PKCS7_print_ctx.3ossl(3), PKCS7_RECIP_INFO_free.3ossl(3), PKCS7_RECIP_INFO_new.3ossl(3), PKCS7_SIGNED_free.3ossl(3), PKCS7_SIGNED_new.3ossl(3), PKCS7_SIGN_ENVELOPE_free.3ossl(3), PKCS7_SIGN_ENVELOPE_new.3ossl(3), PKCS7_SIGNER_INFO_free.3ossl(3), PKCS7_SIGNER_INFO_new.3ossl(3), PKCS8_PRIV_KEY_INFO_free.3ossl(3), PKCS8_PRIV_KEY_INFO_new.3ossl(3), PKEY_USAGE_PERIOD_free.3ossl(3), PKEY_USAGE_PERIOD_new.3ossl(3), POLICY_CONSTRAINTS_free.3ossl(3), POLICY_CONSTRAINTS_new.3ossl(3), POLICYINFO_free.3ossl(3), POLICYINFO_new.3ossl(3), POLICY_MAPPING_free.3ossl(3), POLICY_MAPPING_new.3ossl(3), POLICYQUALINFO_free.3ossl(3), POLICYQUALINFO_new.3ossl(3), PROFESSION_INFO_free.3ossl(3), PROFESSION_INFO_new.3ossl(3), PROFESSION_INFOS_free.3ossl(3), PROFESSION_INFOS_new.3ossl(3), PROXY_CERT_INFO_EXTENSION_free.3ossl(3), PROXY_CERT_INFO_EXTENSION_new.3ossl(3), PROXY_POLICY_free.3ossl(3), PROXY_POLICY_new.3ossl(3), RSA_OAEP_PARAMS_free.3ossl(3), RSA_OAEP_PARAMS_new.3ossl(3), RSAPrivateKey_dup.3ossl(3), RSA_PSS_PARAMS_dup.3ossl(3), RSA_PSS_PARAMS_free.3ossl(3), RSA_PSS_PARAMS_new.3ossl(3), RSAPublicKey_dup.3ossl(3), SCRYPT_PARAMS_free.3ossl(3), SCRYPT_PARAMS_new.3ossl(3), SXNET_free.3ossl(3), SXNETID_free.3ossl(3), SXNETID_new.3ossl(3), SXNET_new.3ossl(3), TLS_FEATURE_free.3ossl(3), TLS_FEATURE_new.3ossl(3), TS_ACCURACY_dup.3ossl(3), TS_ACCURACY_free.3ossl(3), TS_ACCURACY_new.3ossl(3), TS_MSG_IMPRINT_dup.3ossl(3), TS_MSG_IMPRINT_free.3ossl(3), TS_MSG_IMPRINT_new.3ossl(3), TS_REQ_dup.3ossl(3), TS_REQ_free.3ossl(3), TS_REQ_new.3ossl(3), TS_RESP_dup.3ossl(3), TS_RESP_free.3ossl(3), TS_RESP_new.3ossl(3), TS_STATUS_INFO_dup.3ossl(3), TS_STATUS_INFO_free.3ossl(3), TS_STATUS_INFO_new.3ossl(3), TS_TST_INFO_dup.3ossl(3), TS_TST_INFO_free.3ossl(3), TS_TST_INFO_new.3ossl(3), USERNOTICE_free.3ossl(3), USERNOTICE_new.3ossl(3), X509_ALGOR_free.3ossl(3), X509_ALGOR_it.3ossl(3), X509_ALGOR_new.3ossl(3), X509_ATTRIBUTE_dup.3ossl(3), X509_ATTRIBUTE_free.3ossl(3), X509_ATTRIBUTE_new.3ossl(3), X509_CERT_AUX_free.3ossl(3), X509_CERT_AUX_new.3ossl(3), X509_CINF_free.3ossl(3), X509_CINF_new.3ossl(3), X509_CRL_dup.3ossl(3), X509_CRL_free.3ossl(3), X509_CRL_INFO_free.3ossl(3), X509_CRL_INFO_new.3ossl(3), X509_CRL_new.3ossl(3), X509_CRL_new_ex.3ossl(3), X509_EXTENSION_dup.3ossl(3), X509_EXTENSION_free.3ossl(3), X509_EXTENSION_new.3ossl(3), X509_NAME_dup.3ossl(3), X509_NAME_ENTRY_dup.3ossl(3), X509_NAME_ENTRY_free.3ossl(3), X509_NAME_ENTRY_new.3ossl(3), X509_NAME_free.3ossl(3), X509_NAME_new.3ossl(3), X509_REQ_dup.3ossl(3), X509_REQ_free.3ossl(3), X509_REQ_INFO_free.3ossl(3), X509_REQ_INFO_new.3ossl(3), X509_REQ_new.3ossl(3), X509_REQ_new_ex.3ossl(3), X509_REVOKED_dup.3ossl(3), X509_REVOKED_free.3ossl(3), X509_REVOKED_new.3ossl(3), X509_SIG_free.3ossl(3), X509_SIG_new.3ossl(3), X509_VAL_free.3ossl(3) and X509_VAL_new.3ossl(3) are aliases of X509_dup.3ossl(3).

2024-09-12 3.2.2 OpenSSL