|
char * | M_tls_rsa_generate_key (size_t bits) |
|
M_tls_x509_t * | M_tls_x509_new (const char *rsa_privkey) |
|
void | M_tls_x509_destroy (M_tls_x509_t *x509) |
|
M_bool | M_tls_x509_txt_add (M_tls_x509_t *x509, M_tls_x509_txt_t type, const char *text, M_bool append) |
|
M_bool | M_tls_x509_txt_SAN_add (M_tls_x509_t *x509, M_tls_x509_san_type_t type, const char *text, M_bool append) |
|
char * | M_tls_x509_write_csr (M_tls_x509_t *x509) |
|
M_tls_x509_t * | M_tls_x509_read_csr (const char *csr) |
|
M_tls_x509_t * | M_tls_x509_read_crt (const char *crt) |
|
char * | M_tls_x509_selfsign (M_tls_x509_t *x509, M_uint64 valid_secs) |
|
char * | M_tls_x509_sign (M_tls_x509_t *x509, const char *cacert, const char *caprivkey, M_uint64 valid_secs) |
|
M_time_t | M_tls_x509_time_start (M_tls_x509_t *x509) |
|
M_time_t | M_tls_x509_time_end (M_tls_x509_t *x509) |
|
char * | M_tls_x509_subject_name (M_tls_x509_t *x509) |
|
char * | M_tls_x509_issuer_name (M_tls_x509_t *x509) |
|
char * | M_tls_x509_signature (M_tls_x509_t *x509, M_tls_x509_sig_alg_t alg) |
|
unsigned char * | M_tls_dhparam_generate (size_t bits, size_t *out_len) |
|
Basic TLS certificate functionality. This is primary used to aid in generating self signed certificates programmatically.
Example generating a CA, server certificate and signing the certificate with the CA.
#include <mstdlib/mstdlib.h>
#include <mstdlib/mstdlib_tls.h>
#define VALID_SEC (5*365*24*60*60)
int main(int argc, char **argv)
{
char *CA_privkey;
char *CA_crt;
char *Server_privkey;
char *Server_crt;
char *Server_csr;
Server_crt =
M_tls_x509_sign(Server_csr_x509, CA_crt, CA_privkey, VALID_SEC);
M_printf(
"CA Priv Key:\n%s\n", CA_privkey);
M_printf(
"Server Priv Key:\n%s\n", Server_privkey);
M_printf(
"Server CSR:\n%s\n", Server_csr);
M_printf(
"Server CRT:\n%s\n", Server_crt);
}
ssize_t M_printf(const char *fmt,...)
void M_free(void *ptr) M_FREE(1)
struct M_tls_x509 M_tls_x509_t
Definition: m_tls_certs.h:107
M_bool M_tls_x509_txt_SAN_add(M_tls_x509_t *x509, M_tls_x509_san_type_t type, const char *text, M_bool append)
M_tls_x509_t * M_tls_x509_new(const char *rsa_privkey)
M_tls_x509_t * M_tls_x509_read_csr(const char *csr)
char * M_tls_rsa_generate_key(size_t bits)
char * M_tls_x509_selfsign(M_tls_x509_t *x509, M_uint64 valid_secs)
M_bool M_tls_x509_txt_add(M_tls_x509_t *x509, M_tls_x509_txt_t type, const char *text, M_bool append)
char * M_tls_x509_sign(M_tls_x509_t *x509, const char *cacert, const char *caprivkey, M_uint64 valid_secs)
void M_tls_x509_destroy(M_tls_x509_t *x509)
char * M_tls_x509_write_csr(M_tls_x509_t *x509)
@ M_TLS_X509_TXT_ORGANIZATION
Definition: m_tls_certs.h:113
@ M_TLS_X509_TXT_COMMONNAME
Definition: m_tls_certs.h:112
@ M_TLS_X509_SAN_TYPE_DNS
Definition: m_tls_certs.h:131