![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
X.509 helpers implementation: CA generation and per-host leaf minting. More...
#include "nilorea/n_x509.h"#include "nilorea/n_common.h"#include "nilorea/n_log.h"#include <arpa/inet.h>#include <string.h>#include <openssl/bn.h>#include <openssl/err.h>#include <openssl/evp.h>#include <openssl/pem.h>#include <openssl/rsa.h>#include <openssl/x509.h>#include <openssl/x509v3.h>Go to the source code of this file.
Macros | |
| #define | BN_RAND_BOTTOM_ANY 0 |
| BN_rand(): leave the least significant bit unconstrained. | |
| #define | BN_RAND_TOP_ANY (-1) |
| BN_rand(): leave the most significant bit unconstrained. | |
| #define | N_X509_EXT_VALUE(v) |
| pre-1.1.0 X509V3_EXT_conf_nid() declares value as char*, it does not write to it | |
| #define | N_X509_INIT() |
| populate the EVP algorithm table once, no-op from 1.1.0 on | |
| #define | N_X509_KEY_BITS 2048 |
| RSA modulus size in bits used for the CA and leaf keys. | |
| #define | N_X509_SAN_BUF 300 |
| buffer size for a subjectAltName value string | |
| #define | N_X509_SERIAL_BITS 64 |
| random serial number size in bits | |
| #define | X509_getm_notAfter(x) |
| pre-1.1.0 spelling of the mutable notAfter accessor | |
| #define | X509_getm_notBefore(x) |
| pre-1.1.0 spelling of the mutable notBefore accessor | |
Functions | |
| static int | add_ext (X509 *issuer, X509 *subject, int nid, const char *value) |
| static int | bio_to_nstr (BIO *bio, N_STR **out) |
| static EVP_PKEY * | gen_rsa (int bits) |
| static int | host_is_ip (const char *host) |
| int | n_x509_generate_ca (const char *cn, int days, N_STR **ca_cert_pem, N_STR **ca_key_pem) |
| Generate a self-signed certificate authority (CA) keypair and cert. | |
| static void | n_x509_init_openssl (void) |
| int | n_x509_keypair_pem (int bits, N_STR **key_pem) |
| Generate an RSA private key and return it as a PEM string. | |
| int | n_x509_mint_host_cert (const char *host, const N_STR *ca_cert_pem, const N_STR *ca_key_pem, int days, N_STR **leaf_cert_pem, N_STR **leaf_key_pem) |
| Mint a per-host leaf certificate signed by the given CA. | |
| static int | pkey_to_pem (EVP_PKEY *pkey, N_STR **out) |
| static int | set_cn (X509_NAME *name, const char *cn) |
| static int | set_random_serial (X509 *x) |
| static int | x509_to_pem (X509 *x, N_STR **out) |
Variables | |
| static pthread_once_t | n_x509_once = PTHREAD_ONCE_INIT |
X.509 helpers implementation: CA generation and per-host leaf minting.
Definition in file n_x509.c.
| #define BN_RAND_BOTTOM_ANY 0 |
BN_rand(): leave the least significant bit unconstrained.
Definition at line 64 of file n_x509.c.
Referenced by set_random_serial().
| #define BN_RAND_TOP_ANY (-1) |
BN_rand(): leave the most significant bit unconstrained.
Definition at line 60 of file n_x509.c.
Referenced by set_random_serial().
| #define N_X509_EXT_VALUE | ( | v | ) |
| #define N_X509_INIT | ( | ) |
populate the EVP algorithm table once, no-op from 1.1.0 on
Definition at line 98 of file n_x509.c.
Referenced by n_x509_generate_ca(), n_x509_keypair_pem(), and n_x509_mint_host_cert().
| #define N_X509_KEY_BITS 2048 |
RSA modulus size in bits used for the CA and leaf keys.
Definition at line 105 of file n_x509.c.
Referenced by n_x509_generate_ca(), n_x509_keypair_pem(), and n_x509_mint_host_cert().
| #define N_X509_SAN_BUF 300 |
buffer size for a subjectAltName value string
Definition at line 109 of file n_x509.c.
Referenced by n_x509_mint_host_cert().
| #define N_X509_SERIAL_BITS 64 |
random serial number size in bits
Definition at line 107 of file n_x509.c.
Referenced by set_random_serial().
| #define X509_getm_notAfter | ( | x | ) |
pre-1.1.0 spelling of the mutable notAfter accessor
Definition at line 72 of file n_x509.c.
Referenced by n_x509_generate_ca(), and n_x509_mint_host_cert().
| #define X509_getm_notBefore | ( | x | ) |
pre-1.1.0 spelling of the mutable notBefore accessor
Definition at line 68 of file n_x509.c.
Referenced by n_x509_generate_ca(), and n_x509_mint_host_cert().
|
static |
Definition at line 164 of file n_x509.c.
References N_X509_EXT_VALUE.
Referenced by n_x509_generate_ca(), and n_x509_mint_host_cert().
|
static |
Definition at line 113 of file n_x509.c.
References char_to_nstr_ex().
Referenced by pkey_to_pem(), and x509_to_pem().
|
static |
Definition at line 198 of file n_x509.c.
Referenced by n_x509_generate_ca(), n_x509_keypair_pem(), and n_x509_mint_host_cert().
|
static |
Definition at line 187 of file n_x509.c.
Referenced by n_x509_mint_host_cert().
|
static |
Definition at line 125 of file n_x509.c.
References bio_to_nstr().
Referenced by n_x509_generate_ca(), n_x509_keypair_pem(), and n_x509_mint_host_cert().
|
static |
Definition at line 180 of file n_x509.c.
Referenced by n_x509_generate_ca(), and n_x509_mint_host_cert().
|
static |
Definition at line 149 of file n_x509.c.
References BN_RAND_BOTTOM_ANY, BN_RAND_TOP_ANY, and N_X509_SERIAL_BITS.
Referenced by n_x509_generate_ca(), and n_x509_mint_host_cert().
|
static |
Definition at line 137 of file n_x509.c.
References bio_to_nstr().
Referenced by n_x509_generate_ca(), and n_x509_mint_host_cert().