summaryrefslogtreecommitdiff
path: root/libfetch/openssl-compat.h
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2017-10-06 13:23:54 +0300
committerTimo Teräs <timo.teras@iki.fi>2017-10-06 13:25:27 +0300
commiteb8f44d629aca3a780f7feedfee11794f14082ad (patch)
treec6e198874a9063881e6bba27d1e48d755e8e240c /libfetch/openssl-compat.h
parent52fd85a8dcfee9c93522d80693673bc95cc1caaf (diff)
downloadapk-tools-eb8f44d629aca3a780f7feedfee11794f14082ad.tar.gz
apk-tools-eb8f44d629aca3a780f7feedfee11794f14082ad.tar.bz2
apk-tools-eb8f44d629aca3a780f7feedfee11794f14082ad.tar.xz
apk-tools-eb8f44d629aca3a780f7feedfee11794f14082ad.zip
libfetch: improve openssl/libressl compatibility
X509_check_host() is introduced in libressl-2.5.0 and openssl-1.0.2 which are not yet universally available. Add support for building against the older versions.
Diffstat (limited to 'libfetch/openssl-compat.h')
-rw-r--r--libfetch/openssl-compat.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/libfetch/openssl-compat.h b/libfetch/openssl-compat.h
new file mode 100644
index 0000000..6b72fda
--- /dev/null
+++ b/libfetch/openssl-compat.h
@@ -0,0 +1,33 @@
+#include <openssl/crypto.h>
+#include <openssl/x509.h>
+#include <openssl/x509v3.h>
+#include <openssl/pem.h>
+#include <openssl/ssl.h>
+#include <openssl/err.h>
+
+#ifndef X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT
+#define OSSL_COMPAT_NEED_X509_CHECK 1
+
+/* Flags for X509_check_* functions */
+/* Always check subject name for host match even if subject alt names present */
+#define X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT 0x1
+/* Disable wildcard matching for dnsName fields and common name. */
+#define X509_CHECK_FLAG_NO_WILDCARDS 0x2
+/* Wildcards must not match a partial label. */
+#define X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS 0x4
+/* Allow (non-partial) wildcards to match multiple labels. */
+#define X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS 0x8
+/* Constraint verifier subdomain patterns to match a single labels. */
+#define X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS 0x10
+
+/*
+ * Match reference identifiers starting with "." to any sub-domain.
+ * This is a non-public flag, turned on implicitly when the subject
+ * reference identity is a DNS name.
+ */
+#define _X509_CHECK_FLAG_DOT_SUBDOMAINS 0x8000
+
+int X509_check_host(X509 *x, const char *chk, size_t chklen,
+ unsigned int flags, char **peername);
+
+#endif