Sortix cross-nightly manual
This manual documents Sortix cross-nightly. You can instead view this document in the latest official manual.
NAME
STACK_OF — variable-sized arrays of pointers, called OpenSSL stacksDESCRIPTION
The <openssl/safestack.h> header provides a fragile, unusually complicated system of macro-generated wrappers around the functions described in the OPENSSL_sk_new(3) manual page. It is intended to implement superficially type-safe variable-sized arrays of pointers, somewhat misleadingly called “stacks” by OpenSSL. Due to the excessive number of API functions, it is impossible to properly document this system. In particular, calling man(1) for any of the functions operating on stacks cannot yield any result.STACK_OF(X509) my_certificates
’; it is only possible to define pointers to stacks, for example ‘STACK_OF(X509) *my_certificates
’. The only way such pointers can ever be used is by wrapper functions casting them to the type _STACK * described in OPENSSL_sk_new(3).STACK_OF(ACCESS_DESCRIPTION) | AUTHORITY_INFO_ACCESS |
STACK_OF(ASN1_OBJECT) | EXTENDED_KEY_USAGE |
STACK_OF(ASN1_TYPE) | ASN1_SEQUENCE_ANY |
STACK_OF(DIST_POINT) | CRL_DIST_POINTS |
STACK_OF(GENERAL_NAME) | GENERAL_NAMES |
STACK_OF(IPAddressFamily) | IPAddrBlocks |
STACK_OF(POLICY_MAPPING) | POLICY_MAPPINGS |
STACK_OF(POLICYINFO) | CERTIFICATEPOLICIES |
STACK_OF(X509_ALGOR) | X509_ALGORS |
STACK_OF(X509_EXTENSION) | X509_EXTENSIONS |
EXAMPLES
The following program creates a certificate object, puts two pointers to it on a stack, and uses X509_free(3) to clean up properly:#include <err.h> #include <stdio.h> #include <openssl/x509.h> int main(void) { STACK_OF(X509) *stack; X509 *x; if ((stack = sk_X509_new_null()) == NULL) err(1, NULL); if ((x = X509_new()) == NULL) err(1, NULL); if (sk_X509_push(stack, x) == 0) err(1, NULL); if (X509_up_ref(x) == 0) errx(1, "X509_up_ref failed"); if (sk_X509_push(stack, x) == 0) err(1, NULL); printf("%d pointers: %p, %p\n", sk_X509_num(stack), sk_X509_value(stack, 0), sk_X509_value(stack, 1)); sk_X509_pop_free(stack, X509_free); return 0; }
2 pointers: 0x4693ff24c00, 0x4693ff24c00