#define __OPENSSL_110_CONST__
#endif
+#if (HA_OPENSSL_VERSION_NUMBER >= 0x40000000L) && (!defined(USE_OPENSSL_WOLFSSL))
+#define __X509_NAME_CONST__ const
+#else
+#define __X509_NAME_CONST__
+#endif
+
/* ERR_remove_state() was deprecated in 1.0.0 in favor of
* ERR_remove_thread_state(), which was in turn deprecated in
* 1.1.0 and does nothing anymore. Let's simply silently kill
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,
+int ssl_sock_get_dn_entry(__X509_NAME_CONST__ 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);
+int ssl_sock_get_dn_formatted(__X509_NAME_CONST__ X509_NAME *a, const struct buffer *format, struct buffer *out);
+int ssl_sock_get_dn_oneline(__X509_NAME_CONST__ X509_NAME *a, struct buffer *out);
X509* ssl_sock_get_peer_certificate(SSL *ssl);
X509* ssl_sock_get_verified_chain_root(SSL *ssl);
unsigned int openssl_version_parser(const char *version);
int i;
int write = -1;
unsigned int len = 0;
- X509_NAME *name = NULL;
+ __X509_NAME_CONST__ X509_NAME *name = NULL;
if (!tmp)
return -1;
BIO *bio = NULL;
struct buffer *tmp = alloc_trash_chunk();
long version;
- X509_NAME *issuer;
+ __X509_NAME_CONST__ X509_NAME *issuer;
int write = -1;
#ifndef USE_OPENSSL_WOLFSSL
STACK_OF(X509_REVOKED) *rev = NULL;
EVP_PKEY *pkey = NULL;
SSL *tmp_ssl = NULL;
CONF *ctmp = NULL;
- X509_NAME *name;
+ __X509_NAME_CONST__ X509_NAME *name;
+ X509_NAME *subject = NULL;
const EVP_MD *digest;
X509V3_CTX ctx;
unsigned int i;
goto mkcert_error;
/* Set the subject name using the same, but the CN */
- name = X509_NAME_dup(name);
+ subject = X509_NAME_dup(name);
if (strlen(servername) <= 64) {
- if (X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC,
+ if (X509_NAME_add_entry_by_txt(subject, "CN", MBSTRING_ASC,
(const unsigned char *)servername,
-1, -1, 0) != 1) {
- X509_NAME_free(name);
+ X509_NAME_free(subject);
goto mkcert_error;
}
}
- if (X509_set_subject_name(newcrt, name) != 1) {
- X509_NAME_free(name);
+ if (X509_set_subject_name(newcrt, subject) != 1) {
+ X509_NAME_free(subject);
goto mkcert_error;
}
- X509_NAME_free(name);
+ X509_NAME_free(subject);
/* Add x509v3 extensions as specified */
ctmp = NCONF_new(NULL);
smp_fetch_ssl_r_dn(const struct arg *args, struct sample *smp, const char *kw, void *private)
{
X509 *crt = NULL;
- X509_NAME *name;
+ __X509_NAME_CONST__ X509_NAME *name;
int ret = 0;
struct buffer *smp_trash;
struct connection *conn;
int cert_peer = (kw[4] == 'c' || kw[4] == 's') ? 1 : 0;
int conn_server = (kw[4] == 's') ? 1 : 0;
X509 *crt = NULL;
- X509_NAME *name;
+ __X509_NAME_CONST__ X509_NAME *name;
int ret = 0;
struct buffer *smp_trash;
struct connection *conn;
int cert_peer = (kw[4] == 'c' || kw[4] == 's') ? 1 : 0;
int conn_server = (kw[4] == 's') ? 1 : 0;
X509 *crt = NULL;
- X509_NAME *name;
+ __X509_NAME_CONST__ X509_NAME *name;
int ret = 0;
struct buffer *smp_trash;
struct connection *conn;
STACK_OF(X509_OBJECT) *objs;
STACK_OF(X509_NAME) *skn;
X509 *x;
- X509_NAME *xn;
+ __X509_NAME_CONST__ X509_NAME *xn;
+ X509_NAME *xn_dup;
skn = sk_X509_NAME_new_null();
/* take x509 from cafile_tree */
if (ca_name)
continue;
ca_name = calloc(1, sizeof *ca_name);
- xn = X509_NAME_dup(xn);
+ xn_dup = X509_NAME_dup(xn);
if (!ca_name ||
- !xn ||
- !sk_X509_NAME_push(skn, xn)) {
+ !xn_dup ||
+ !sk_X509_NAME_push(skn, xn_dup)) {
free(ca_name);
- X509_NAME_free(xn);
+ X509_NAME_free(xn_dup);
sk_X509_NAME_pop_free(skn, X509_NAME_free);
sk_X509_NAME_free(skn);
skn = NULL;
break;
}
ca_name->node.key = key;
- ca_name->xname = xn;
+ ca_name->xname = xn_dup;
eb64_insert(&ca_name_tree, &ca_name->node);
}
sk_X509_OBJECT_popX_free(objs, X509_OBJECT_free);
SSL_CTX *ctx;
int i;
int order = 0;
- X509_NAME *xname;
+ __X509_NAME_CONST__ X509_NAME *xname;
char *str;
EVP_PKEY *pkey;
struct pkey_info kinfo = { .sig = TLSEXT_signature_anonymous, .bits = 0 };
xname = X509_get_subject_name(data->cert);
i = -1;
while ((i = X509_NAME_get_index_by_NID(xname, NID_commonName, i)) != -1) {
- X509_NAME_ENTRY *entry = X509_NAME_get_entry(xname, i);
- ASN1_STRING *value;
+ __X509_NAME_CONST__ X509_NAME_ENTRY *entry = X509_NAME_get_entry(xname, i);
+ __X509_NAME_CONST__ ASN1_STRING *value;
value = X509_NAME_ENTRY_get_data(entry);
if (ASN1_STRING_to_UTF8((unsigned char **)&str, value) >= 0) {
X509 *cert;
STACK_OF(GENERAL_NAME) *alt_names;
int i;
- X509_NAME *cert_subject;
+ __X509_NAME_CONST__ X509_NAME *cert_subject;
char *str;
if (ok == 0)
cert_subject = X509_get_subject_name(cert);
i = -1;
while (!ok && (i = X509_NAME_get_index_by_NID(cert_subject, NID_commonName, i)) != -1) {
- X509_NAME_ENTRY *entry = X509_NAME_get_entry(cert_subject, i);
- ASN1_STRING *value;
+ __X509_NAME_CONST__ X509_NAME_ENTRY *entry = X509_NAME_get_entry(cert_subject, i);
+ __X509_NAME_CONST__ ASN1_STRING *value;
value = X509_NAME_ENTRY_get_data(entry);
if (ASN1_STRING_to_UTF8((unsigned char **)&str, value) >= 0) {
ok = ssl_sock_srv_hostcheck(str, servername);
{
struct ssl_sock_ctx *ctx = conn_get_ssl_sock_ctx(conn);
X509 *crt = NULL;
- X509_NAME *name;
+ __X509_NAME_CONST__ X509_NAME *name;
const char find_cn[] = "CN";
const struct buffer find_cn_chunk = {
.area = (char *)&find_cn,
int ssl_load_global_issuer_from_BIO(BIO *in, char *fp, char **err)
{
X509 *ca;
- X509_NAME *name = NULL;
+ __X509_NAME_CONST__ X509_NAME *name = NULL;
ASN1_OCTET_STRING *skid = NULL;
STACK_OF(X509) *chain = NULL;
struct issuer_chain *issuer;
X509 *crt = SSL_get_certificate(ssl);
if (crt) {
- X509_NAME *name = X509_get_subject_name(crt);
+ __X509_NAME_CONST__ X509_NAME *name = X509_get_subject_name(crt);
if (name)
chunk_appendf(&trace_buf, " subject=\"%s\"",
X509_NAME_oneline(name, 0, 0));
/* Extract an entry from a X509_NAME and copy its value to an output chunk.
* Returns 1 if entry found, 0 if entry not found, or -1 if output not large enough.
*/
-int ssl_sock_get_dn_entry(X509_NAME *a, const struct buffer *entry, int pos,
+int ssl_sock_get_dn_entry(__X509_NAME_CONST__ X509_NAME *a, const struct buffer *entry, int pos,
struct buffer *out)
{
- X509_NAME_ENTRY *ne;
- ASN1_OBJECT *obj;
- ASN1_STRING *data;
+ __X509_NAME_CONST__ X509_NAME_ENTRY *ne;
+ __X509_NAME_CONST__ ASN1_OBJECT *obj;
+ __X509_NAME_CONST__ ASN1_STRING *data;
const unsigned char *data_ptr;
int data_len;
int i, j, n;
* Currently supports rfc2253 for returning LDAP V3 DNs.
* Returns 1 if dn entries exist, 0 if no dn entry was found.
*/
-int ssl_sock_get_dn_formatted(X509_NAME *a, const struct buffer *format, struct buffer *out)
+int ssl_sock_get_dn_formatted(__X509_NAME_CONST__ X509_NAME *a, const struct buffer *format, struct buffer *out)
{
BIO *bio = NULL;
int ret = 0;
/* Extract and format full DN from a X509_NAME and copy result into a chunk
* Returns 1 if dn entries exits, 0 if no dn entry found or -1 if output is not large enough.
*/
-int ssl_sock_get_dn_oneline(X509_NAME *a, struct buffer *out)
+int ssl_sock_get_dn_oneline(__X509_NAME_CONST__ X509_NAME *a, struct buffer *out)
{
- X509_NAME_ENTRY *ne;
- ASN1_OBJECT *obj;
- ASN1_STRING *data;
+ __X509_NAME_CONST__ X509_NAME_ENTRY *ne;
+ __X509_NAME_CONST__ ASN1_OBJECT *obj;
+ __X509_NAME_CONST__ ASN1_STRING *data;
const unsigned char *data_ptr;
int data_len;
int i, n, ln;