diff --git a/src/openvpn/openssl_compat.h b/src/openvpn/openssl_compat.h
index 8309cee..ae182d2 100644
--- a/src/openvpn/openssl_compat.h
+++ b/src/openvpn/openssl_compat.h
@@ -61,6 +61,14 @@
 typedef uint64_t openssl_opt_t;
 #endif
 
+/* SSL_CTX_set1_groups() length: size_t in LibreSSL and AWS-LC, passed to
+ * SSL_CTX_ctrl() as long by OpenSSL 1.1.1's macro */
+#if defined(LIBRESSL_VERSION_NUMBER) || defined(OPENSSL_IS_AWSLC)
+typedef size_t openssl_groups_len_t;
+#else
+typedef long openssl_groups_len_t;
+#endif
+
 
 /* Functionality missing in LibreSSL before 3.5 */
 #if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x3050000fL
diff --git a/src/openvpn/ssl_openssl.c b/src/openvpn/ssl_openssl.c
index 30ef383..b95de8e 100644
--- a/src/openvpn/ssl_openssl.c
+++ b/src/openvpn/ssl_openssl.c
@@ -535,7 +535,7 @@
     ALLOC_ARRAY_CLEAR_GC(glist, int, groups_count, &gc);
 
     /* Parse allowed ciphers, getting IDs */
-    int glistlen = 0;
+    openssl_groups_len_t glistlen = 0;
     char *tmp_groups = string_alloc(groups, &gc);
 
     const char *token;
