47 int lenpat = strlen(pattern);
48 int lenstr = strlen(
string);
63 if (
pg_strcasecmp(pattern + 1,
string + lenstr - lenpat + 1) != 0)
70 if (strchr(
string,
'.') <
string + lenstr - lenpat)
88 const char *namedata,
size_t namelen,
97 if (!(host && host[0] !=
'\0'))
113 memcpy(
name, namedata, namelen);
114 name[namelen] =
'\0';
120 if (namelen != strlen(
name))
158 const unsigned char *ipdata,
166 char tmp[
sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
171 if (!(host && host[0] !=
'\0'))
198 if (memcmp(ipdata, &addr.s_addr, iplen) == 0)
207 #ifdef HAVE_INET_PTON
208 else if (iplen == 16)
211 struct in6_addr addr;
215 if (inet_pton(AF_INET6, host, &addr) == 1)
217 if (memcmp(ipdata, &addr.s6_addr, iplen) == 0)
242 *store_name = strdup(addrstr);
256 int names_examined = 0;
257 char *first_name = NULL;
267 if (!(host && host[0] !=
'\0'))
283 if (names_examined > 1)
286 libpq_ngettext(
"server certificate for \"%s\" (and %d other name) does not match host name \"%s\"",
287 "server certificate for \"%s\" (and %d other names) does not match host name \"%s\"",
289 first_name, names_examined - 1, host);
292 else if (names_examined == 1)
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)
static bool wildcard_certificate_match(const char *pattern, const char *string)
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)
int pgtls_verify_peer_name_matches_certificate_guts(PGconn *conn, int *names_examined, char **first_name)
#define libpq_ngettext(s, p, n)
#define PG_STRERROR_R_BUFLEN
int pg_strcasecmp(const char *s1, const char *s2)
char * pg_inet_net_ntop(int af, const void *src, int bits, char *dst, size_t size)
int inet_aton(const char *cp, struct in_addr *addr)
void appendPQExpBuffer(PQExpBuffer str, const char *fmt,...)
void appendPQExpBufferChar(PQExpBuffer str, char ch)
PQExpBufferData errorMessage