61#include <openssl/ssl.h>
62#include <openssl/conf.h>
64#include <openssl/engine.h>
66#include <openssl/x509v3.h>
159 "SSL_read failed but did not provide error information\n");
183 "\tThis probably means the server terminated abnormally\n"
184 "\tbefore or while processing the request.");
291 "SSL_write failed but did not provide error information\n");
319 "\tThis probably means the server terminated abnormally\n"
320 "\tbefore or while processing the request.");
392#if HAVE_X509_GET_SIGNATURE_INFO
466#ifdef HAVE_SSL_CTX_SET_CERT_CB
720#ifdef HAVE_SSL_CTX_SET_KEYLOG_CALLBACK
832#ifdef HAVE_SSL_CTX_SET_CERT_CB
932 else if (
fnbuf[0] !=
'\0' &&
966 if ((fname ||
dname) &&
992 if (
fnbuf[0] ==
'\0')
994 "Either provide the file, use the system's trusted roots with sslrootcert=system, or change sslmode to disable server certificate verification.");
997 "Either provide the file, use the system's trusted roots with sslrootcert=system, or change sslmode to disable server certificate verification.",
fnbuf);
1017 else if (
fnbuf[0] ==
'\0')
1086#ifdef HAVE_SSL_CTX_SET_KEYLOG_CALLBACK
1089#ifdef LIBRESSL_VERSION_NUMBER
1114 if (host && host[0] &&
1153#ifdef USE_SSL_ENGINE
1296#if !defined(WIN32) && !defined(__CYGWIN__)
1297 if (
buf.st_uid == 0 ?
1302 "private key file \"%s\" has group or world access; file must have permissions u=rw (0600) or less if owned by the current user, or permissions u=rw,g=r (0640) or less if owned by root",
1381 unsigned long ecode;
1395 unsigned long vcode;
1452#ifdef SSL_R_VERSION_TOO_HIGH
1481 const unsigned char *selected;
1486 if (selected ==
NULL)
1559#ifdef USE_SSL_ENGINE
1581static char ssl_nomem[] =
"out of memory allocating error description";
1583#define SSL_ERR_LEN 128
1588 const char *errreason;
1600 if (errreason !=
NULL)
1614#ifdef SSL_AD_NO_APPLICATION_PROTOCOL
1630#ifdef ERR_SYSTEM_ERROR
1741 const unsigned char *
data;
1786#if defined(EWOULDBLOCK) && (!defined(EAGAIN) || (EWOULDBLOCK != EAGAIN))
1819#if defined(EWOULDBLOCK) && (!defined(EAGAIN) || (EWOULDBLOCK != EAGAIN))
1943 buf[size - 1] =
'\0';
1997#ifdef TLS1_1_VERSION
2002#ifdef TLS1_2_VERSION
2007#ifdef TLS1_3_VERSION
static SSL_CTX * SSL_context
#define unconstify(underlying_type, expr)
#define Assert(condition)
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
#define fprintf(file, fmt, msg)
void err(int eval, const char *fmt,...)
bool pqGetHomeDirectory(char *buf, int bufsize)
void libpq_append_conn_error(PGconn *conn, const char *fmt,...)
int pq_verify_peer_name_matches_certificate_name(PGconn *conn, const char *namedata, size_t namelen, char **store_name)
int pq_verify_peer_name_matches_certificate_ip(PGconn *conn, const unsigned char *ipdata, size_t iplen, char **store_name)
bool pq_verify_peer_name_matches_certificate(PGconn *conn)
static int openssl_verify_peer_name_matches_certificate_name(PGconn *conn, const ASN1_STRING *name_entry, char **store_name)
static BIO_METHOD * pgconn_bio_method_ptr
static int ssl_protocol_version_to_openssl(const char *protocol)
void * PQgetssl(PGconn *conn)
static void SSLerrfree(char *buf)
ssize_t pgtls_bytes_pending(PGconn *conn)
PQsslKeyPassHook_OpenSSL_type PQgetSSLKeyPassHook_OpenSSL(void)
void * PQsslStruct(PGconn *conn, const char *struct_name)
int pgtls_verify_peer_name_matches_certificate_guts(PGconn *conn, int *names_examined, char **first_name)
PostgresPollingStatusType pgtls_open_client(PGconn *conn)
int PQdefaultSSLKeyPassHook_OpenSSL(char *buf, int size, PGconn *conn)
static int pgconn_bio_read(BIO *h, char *buf, int size)
ssize_t pgtls_read(PGconn *conn, void *ptr, size_t len)
static long pgconn_bio_ctrl(BIO *h, int cmd, long num, void *ptr)
static int pgconn_bio_write(BIO *h, const char *buf, int size)
ssize_t pgtls_write(PGconn *conn, const void *ptr, size_t len)
static PQsslKeyPassHook_OpenSSL_type PQsslKeyPassHook
char * pgtls_get_peer_certificate_hash(PGconn *conn, size_t *len)
const char * PQsslAttribute(PGconn *conn, const char *attribute_name)
static int initialize_SSL(PGconn *conn)
static pthread_mutex_t ssl_config_mutex
static int verify_cb(int ok, X509_STORE_CTX *ctx)
static int PQssl_passwd_cb(char *buf, int size, int rwflag, void *userdata)
static char * SSLerrmessage(unsigned long ecode)
static int openssl_verify_peer_name_matches_certificate_ip(PGconn *conn, ASN1_OCTET_STRING *addr_entry, char **store_name)
static PostgresPollingStatusType open_client_SSL(PGconn *conn)
static unsigned char alpn_protos[]
static int ssl_set_pgconn_bio(PGconn *conn)
void pgtls_close(PGconn *conn)
const char *const * PQsslAttributeNames(PGconn *conn)
void PQsetSSLKeyPassHook_OpenSSL(PQsslKeyPassHook_OpenSSL_type hook)
static BIO_METHOD * pgconn_bio_method(void)
static bool is_ip_address(const char *host)
ssize_t pqsecure_raw_read(PGconn *conn, void *ptr, size_t len)
ssize_t pqsecure_raw_write(PGconn *conn, const void *ptr, size_t len)
int(* PQsslKeyPassHook_OpenSSL_type)(char *buf, int size, PGconn *conn)
PostgresPollingStatusType
#define SOCK_ERRNO_SET(e)
static char buf[DEFAULT_XLOG_SEG_SIZE]
#define PG_STRERROR_R_BUFLEN
int pg_strcasecmp(const char *s1, const char *s2)
int inet_aton(const char *cp, struct in_addr *addr)
size_t strlcpy(char *dst, const char *src, size_t siz)
#define PG_ALPN_PROTOCOL_VECTOR
void appendPQExpBufferStr(PQExpBuffer str, const char *data)
static int fd(const char *x, int i)
int pthread_mutex_unlock(pthread_mutex_t *mp)
int pthread_mutex_lock(pthread_mutex_t *mp)
#define PTHREAD_MUTEX_INITIALIZER
static unsigned hash(unsigned *uv, int n)
char * ssl_max_protocol_version
char * ssl_min_protocol_version
PQExpBufferData errorMessage
bool ssl_handshake_started