2020-05-15 06:01:17 -04:00
|
|
|
/*
|
2020-06-04 08:21:22 -04:00
|
|
|
* include/haproxy/ssl_utils.h
|
2020-05-15 06:01:17 -04:00
|
|
|
*
|
|
|
|
|
* Utility functions for SSL:
|
|
|
|
|
* Mostly generic functions that retrieve information from certificates
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2012 EXCELIANCE, Emeric Brun <ebrun@exceliance.fr>
|
|
|
|
|
* Copyright (C) 2020 HAProxy Technologies, William Lallemand <wlallemand@haproxy.com>
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation, version 2.1
|
|
|
|
|
* exclusively.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
*/
|
|
|
|
|
|
2020-06-04 08:21:22 -04:00
|
|
|
#ifndef _HAPROXY_SSL_UTILS_H
|
|
|
|
|
#define _HAPROXY_SSL_UTILS_H
|
|
|
|
|
|
2020-05-15 06:01:17 -04:00
|
|
|
#ifdef USE_OPENSSL
|
|
|
|
|
|
2020-06-04 08:21:22 -04:00
|
|
|
#include <haproxy/buf-t.h>
|
|
|
|
|
#include <haproxy/openssl-compat.h>
|
|
|
|
|
|
2020-05-15 06:01:17 -04:00
|
|
|
int cert_get_pkey_algo(X509 *crt, struct buffer *out);
|
|
|
|
|
int ssl_sock_get_serial(X509 *crt, struct buffer *out);
|
|
|
|
|
int ssl_sock_crt2der(X509 *crt, struct buffer *out);
|
|
|
|
|
int ssl_sock_get_time(ASN1_TIME *tm, struct buffer *out);
|
|
|
|
|
int ssl_sock_get_dn_entry(X509_NAME *a, const struct buffer *entry, int pos,
|
|
|
|
|
struct buffer *out);
|
|
|
|
|
int ssl_sock_get_dn_formatted(X509_NAME *a, const struct buffer *format, struct buffer *out);
|
|
|
|
|
int ssl_sock_get_dn_oneline(X509_NAME *a, struct buffer *out);
|
2021-08-19 12:06:30 -04:00
|
|
|
X509* ssl_sock_get_peer_certificate(SSL *ssl);
|
2023-05-13 23:04:45 -04:00
|
|
|
X509* ssl_sock_get_verified_chain_root(SSL *ssl);
|
2021-08-21 17:16:06 -04:00
|
|
|
unsigned int openssl_version_parser(const char *version);
|
2021-07-13 09:14:21 -04:00
|
|
|
void exclude_tls_grease(char *input, int len, struct buffer *output);
|
2022-11-03 11:31:50 -04:00
|
|
|
int x509_v_err_str_to_int(const char *str);
|
|
|
|
|
const char *x509_v_err_int_to_str(int code);
|
2022-12-20 05:11:17 -05:00
|
|
|
long asn1_generalizedtime_to_epoch(ASN1_GENERALIZEDTIME *d);
|
2024-12-06 11:42:19 -05:00
|
|
|
const char *x509_get_notbefore(X509 *cert);
|
|
|
|
|
const char *x509_get_notafter(X509 *cert);
|
2024-12-16 06:34:56 -05:00
|
|
|
#ifdef HAVE_ASN1_TIME_TO_TM
|
|
|
|
|
time_t ASN1_to_time_t(ASN1_TIME *asn1_time);
|
|
|
|
|
time_t x509_get_notafter_time_t(X509 *cert);
|
2025-05-02 08:42:28 -04:00
|
|
|
time_t x509_get_notbefore_time_t(X509 *cert);
|
2024-12-16 06:34:56 -05:00
|
|
|
#endif
|
2025-04-02 13:34:09 -04:00
|
|
|
int curves2nid(const char *curve);
|
|
|
|
|
const char *nid2nist(int nid);
|
2025-04-18 11:26:49 -04:00
|
|
|
const char *sigalg2str(int sigalg);
|
2025-07-15 04:45:08 -04:00
|
|
|
const char *curveid2str(int curve_id);
|
2021-08-19 12:06:30 -04:00
|
|
|
|
2026-01-13 05:50:56 -05:00
|
|
|
int aes_process(struct buffer *data, struct buffer *nonce, struct buffer *key, int key_size,
|
|
|
|
|
struct buffer *aead_tag, struct buffer *aad, struct buffer *out, int decrypt, int gcm);
|
|
|
|
|
|
2020-06-04 08:21:22 -04:00
|
|
|
#endif /* _HAPROXY_SSL_UTILS_H */
|
2020-05-15 06:01:17 -04:00
|
|
|
#endif /* USE_OPENSSL */
|
|
|
|
|
|