GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
X509_ATTRIBUTE_SET1_OBJECT(3) FreeBSD Library Functions Manual X509_ATTRIBUTE_SET1_OBJECT(3)

X509_ATTRIBUTE_set1_object, X509_ATTRIBUTE_set1_data, X509_ATTRIBUTE_create_by_OBJ, X509_ATTRIBUTE_create_by_NID, X509_ATTRIBUTE_create_by_txt
modify an X.501 Attribute

#include <openssl/x509.h>

int
X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj);

int
X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int type, const void *data, int len);

X509_ATTRIBUTE *
X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **pattr, const ASN1_OBJECT *obj, int type, const void *data, int len);

X509_ATTRIBUTE *
X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **pattr, int nid, int type, const void *data, int len);

X509_ATTRIBUTE *
X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **pattr, const char *name, int type, const unsigned char *data, int len);

X509_ATTRIBUTE_set1_object() sets the type of attr to obj. If obj is dynamically allocated, a deep copy is created. If the type of attr was already set, the old type is freed as far as it was dynamically allocated. After calling this function, attr may be in an inconsistent state because its values may not agree with the new attribute type.

X509_ATTRIBUTE_set1_data() sets attr to be multi-valued and initializes its set of values to contain a single new ASN.1 ANY object representing the data.

The interpretation of the data depends on the values of the type and len arguments; there are four different cases.

If the type argument has the bit MBSTRING_FLAG set, data is expected to point to a multibyte character string that is len bytes long and uses the encoding specified by the type argument, and it is expected that an attribute type was already assigned to attr, for example by calling X509_ATTRIBUTE_set1_object() before calling X509_ATTRIBUTE_set1_data(). In this case, an appropriate ASN.1 multibyte string type is chosen and a new object of that type is allocated and populated to represent the data by calling ASN1_STRING_set_by_NID(3). The type of that new ASN.1 string object is subsequently used instead of the type argument.

If the type argument does not have the bit MBSTRING_FLAG set and the len argument is not -1, the type argument is expected to be one of the types documented in ASN1_STRING_new(3) and data is expected to point to a buffer of len bytes. In this case, a new object is allocated with ASN1_STRING_type_new(3) and populated with ASN1_STRING_set(3).

If the type argument does not have the bit MBSTRING_FLAG set and the len argument is -1, data is expected to point to an object of the given type rather than to a buffer. In this case, a deep copy of the existing object into the new ASN.1 ANY object is performed with ASN1_TYPE_set1(3).

If the type argument is 0, the data and len arguments are ignored and the set of values is left empty instead of adding a single ASN.1 ANY object to it. This violates section 8.2 of the X.501 standard, which requires every attribute to contain at least one value, but some attribute types used by the library use empty sets of values anyway.

X509_ATTRIBUTE_create_by_OBJ() sets the type of **attr to obj using X509_ATTRIBUTE_set1_object() and copies the data into it using X509_ATTRIBUTE_set1_data(). If attr or *attr is NULL, a new X509_ATTRIBUTE object is allocated, populated, and returned.

X509_ATTRIBUTE_create_by_NID() is a wrapper around X509_ATTRIBUTE_create_by_OBJ() that obtains the required obj argument by calling OBJ_nid2obj(3) on the nid argument.

X509_ATTRIBUTE_create_by_txt() is a similar wrapper that obtains obj by calling OBJ_txt2obj(3) with the arguments name and 0, which means that long names, short names, and numerical OID strings are all acceptable.

X509_ATTRIBUTE_set1_object() returns 1 if successful or 0 if attr or obj is NULL or if memory allocation fails.

X509_ATTRIBUTE_set1_data() returns 1 if successful or 0 if attr is NULL or if ASN1_STRING_set_by_NID(3), ASN1_STRING_set(3), ASN1_TYPE_set1(3), or memory allocation fails.

X509_ATTRIBUTE_create_by_OBJ(), X509_ATTRIBUTE_create_by_NID(), and X509_ATTRIBUTE_create_by_txt() return a pointer to the changed or new object or NULL if obtaining obj, allocating memory, or copying fails.

ASN1_OBJECT_new(3), ASN1_STRING_new(3), ASN1_STRING_set(3), ASN1_STRING_set_by_NID(3), ASN1_TYPE_new(3), OBJ_nid2obj(3), X509_ATTRIBUTE_get0_object(3), X509_ATTRIBUTE_new(3)

These functions first appeared in OpenSSL 0.9.5 and have been available since OpenBSD 2.7.

If attr already contains one or more values, X509_ATTRIBUTE_set1_data(), X509_ATTRIBUTE_create_by_OBJ(), X509_ATTRIBUTE_create_by_NID(), and X509_ATTRIBUTE_create_by_txt() silently overwrite the pointers to the old values and leak the memory used for them.
November 26, 2021 FreeBSD 13.1-RELEASE

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.