Skip to contentSkip to conversation

Support x509 field list to be username

PATCH Superseded Vladislav Grishenko 4 participants 8 messages Aug 16, 2020 – Oct 8, 2020 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 012001d673632063610612a230yandex-team.ru

#1 lore raw

PATCH v3 1/1 Support x509 field list to be username

OpenVPN has the ability to choose different x509 field in case "CN" can't be use used to be unique connected username since commit 935c62be9c0c8a256112df818bfb8470586a23b6.
Unfortunately it's not enough in case client has multiple and valid certificates from PKI for different devices (ex. laptop, mobile, etc) with the same CN/UID.

Having --duplicate-cn as a workaround helps only partially: clients can be connected, but it breaks coexistance with --ifconfig-pool-persist, --client-config-dir and opens doors to DoS possibility since same client device (with the same cert) being reconnected no more replaces previously connected session, so it can exhaust server resources (ex. address pool) and can prevent other clients to be connected.

With this patch, multiple x509 fields incl. "serialNumber" can be chosen to be username as --x509-username-field space-separated parameters. Multiple fields will be joined into one username using '/' delimeter for consistency with CN/addr logging and preserving ability for hierarchical ccd. As long as resulting username is unique, --duplicate-cn will not be required. Default value is preserved as "CN" only.

Openssl backend is the only supported at the moment, since so far MbedTLS has no alt user name support at all.

v2: conform C99, man update, fix typos
v3: reuse buffer methods, drop delimiter define, use memcpy

---
 doc/man-sections/tls-options.rst |  9 ++++--
 src/openvpn/init.c               |  6 ++--
 src/openvpn/options.c            | 49 +++++++++++++++++---------------
 src/openvpn/options.h            |  4 +--
 src/openvpn/ssl_common.h         |  8 +++++-
 src/openvpn/ssl_verify.c         | 49 +++++++++++++++++++++++++-------
 src/openvpn/ssl_verify_openssl.c | 14 +++++++++
 7 files changed, 96 insertions(+), 43 deletions(-)
doc/man-sections/tls-options.rst +6 -3
index 8c2db7cd..8449f5dc 100644
@@ -632,13 +632,13 @@ certificates and keys: https://github.com/OpenVPN/easy-rsa
   options can be defined to track multiple attributes.
 
 --x509-username-field args
-  Field in the X.509 certificate subject to be used as the username
+  Field list in the X.509 certificate subject to be used as the username
   (default :code:`CN`).
 
   Valid syntax:
   ::
 
-     x509-username-field [ext:]fieldname
+     x509-username-field [ext:]fieldname [[ext:]fieldname...]
 
   Typically, this option is specified with **fieldname** as
   either of the following:
@@ -646,6 +646,7 @@ certificates and keys: https://github.com/OpenVPN/easy-rsa
 
      x509-username-field emailAddress
      x509-username-field ext:subjectAltName
+     x509-username-field CN serialNumber
 
   The first example uses the value of the :code:`emailAddress` attribute
   in the certificate's Subject field as the username. The second example
@@ -653,7 +654,9 @@ certificates and keys: https://github.com/OpenVPN/easy-rsa
   ``fieldname`` :code:`subjectAltName` be searched for an rfc822Name
   (email) field to be used as the username. In cases where there are
   multiple email addresses in :code:`ext:fieldname`, the last occurrence
-  is chosen.
+  is chosen. The last example uses the value of :code:`CN` attribute in
+  the Subject field and the certificate's :code:`serialNumber` field in
+  hex delimited by slash symbol as the resulting username.
 
   When this option is used, the ``--verify-x509-name`` option will match
   against the chosen ``fieldname`` instead of the Common Name.
src/openvpn/init.c +3 -3
index dfa045b0..b748d985 100644
@@ -2905,14 +2905,14 @@ do_init_crypto_tls(struct context *c, const unsigned int flags)
     to.crl_file_inline = options->crl_file_inline;
     to.ssl_flags = options->ssl_flags;
     to.ns_cert_type = options->ns_cert_type;
-    memmove(to.remote_cert_ku, options->remote_cert_ku, sizeof(to.remote_cert_ku));
+    memcpy(to.remote_cert_ku, options->remote_cert_ku, sizeof(to.remote_cert_ku));
     to.remote_cert_eku = options->remote_cert_eku;
     to.verify_hash = options->verify_hash;
     to.verify_hash_algo = options->verify_hash_algo;
 #ifdef ENABLE_X509ALTUSERNAME
-    to.x509_username_field = (char *) options->x509_username_field;
+    memcpy(to.x509_username_field, options->x509_username_field, sizeof(to.x509_username_field));
 #else
-    to.x509_username_field = X509_USERNAME_FIELD_DEFAULT;
+    to.x509_username_field[0] = X509_USERNAME_FIELD_DEFAULT;
 #endif
     to.es = c->c2.es;
     to.net_ctx = &c->net_ctx;
src/openvpn/options.c +26 -23

74 lines not on this page · raw message

src/openvpn/options.h +2 -2
index 877e9396..e527d70e 100644
@@ -584,8 +584,8 @@ struct options
     int handshake_window;
 
 #ifdef ENABLE_X509ALTUSERNAME
-    /* Field used to be the username in X509 cert. */
-    char *x509_username_field;
+    /* Field list used to be the username in X509 cert. */
+    char *x509_username_field[MAX_PARMS];
 #endif
 
     /* Old key allowed to live n seconds after new key goes active */
src/openvpn/ssl_common.h +7 -1
index 96897e48..821dbc8d 100644
@@ -284,7 +284,13 @@ struct tls_options
     const char *remote_cert_eku;
     uint8_t *verify_hash;
     hash_algo_type verify_hash_algo;
-    char *x509_username_field;
+
+    /* Field list used to be the username in X509 cert. */
+#ifdef ENABLE_X509ALTUSERNAME
+    char *x509_username_field[MAX_PARMS];
+#else
+    char *x509_username_field[2];
+#endif
 
     /* allow openvpn config info to be
      * passed over control channel */
src/openvpn/ssl_verify.c +38 -11

65 lines not on this page · raw message

src/openvpn/ssl_verify_openssl.c +14 -0
index 454efeec..9fd3eb50 100644
@@ -269,6 +269,20 @@ backend_x509_get_username(char *common_name, int cn_len,
             return FAILURE;
         }
     }
+    else if (strcmp(LN_serialNumber,x509_username_field) == 0)
+    {
+        ASN1_INTEGER *asn1_i = X509_get_serialNumber(peer_cert);
+        struct gc_arena gc = gc_new();
+        char *serial = format_hex_ex(asn1_i->data, asn1_i->length, 0, 1, NULL, &gc);
+
+        if (!serial || cn_len <= strlen(serial)+2)
+        {
+            gc_free(&gc);
+            return FAILURE;
+        }
+        openvpn_snprintf(common_name, cn_len, "0x%s", serial);
+        gc_free(&gc);
+    }
     else
 #endif
     if (FAILURE == extract_x509_field_ssl(X509_get_subject_name(peer_cert),
Signature · 1 line
2.17.1
#2 lore raw

PATCH v4 1/1 Support X509 field list to be username

OpenVPN has the ability to choose different X509 field in case "CN" can't be use used to be unique connected username since commit 935c62be9c0c8a256112df818bfb8470586a23b6.
Unfortunately it's not enough in case client has multiple and valid certificates from PKI for different devices (ex. laptop, mobile, etc) with the same CN/UID.

Having --duplicate-cn as a workaround helps only partially: clients can be connected, but it breaks coexistance with --ifconfig-pool-persist, --client-config-dir and opens doors to DoS possibility since same client device (with the same cert) being reconnected no more replaces previously connected session, so it can exhaust server resources (ex. address pool) and can prevent other clients to be connected.

With this patch, multiple X509 fields incl. "serialNumber" can be chosen to be username with --x509-username-field space-separated parameters. Multiple fields will be concatened into one username using '_' delimeter. As long as resulting username is unique, --duplicate-cn will not be required. Default value is preserved as "CN" only.

Openssl backend is the only supported at the moment, since so far MbedTLS has no --x509-username-field support at all.

v2: conform C99, man update, fix typos
v3: reuse buffer methods, drop delimiter define, use memcpy
v4: man update, change delimeter "_" to avoid path issues on windows

---
 doc/man-sections/tls-options.rst | 14 +++++----
 src/openvpn/init.c               |  6 ++--
 src/openvpn/options.c            | 49 +++++++++++++++++---------------
 src/openvpn/options.h            |  4 +--
 src/openvpn/ssl_common.h         |  2 +-
 src/openvpn/ssl_verify.c         | 49 +++++++++++++++++++++++++-------
 src/openvpn/ssl_verify_openssl.c | 14 +++++++++
 7 files changed, 93 insertions(+), 45 deletions(-)
doc/man-sections/tls-options.rst +9 -5
index 8c2db7cd..a670578d 100644
@@ -632,13 +632,14 @@ certificates and keys: https://github.com/OpenVPN/easy-rsa
   options can be defined to track multiple attributes.
 
 --x509-username-field args
-  Field in the X.509 certificate subject to be used as the username
-  (default :code:`CN`).
+  Fields in the X.509 certificate subject to be used as the username
+  (default :code:`CN`). If multiple fields are specified their values
+  will be concatenated with :code:`_` delimeter.
 
   Valid syntax:
   ::
 
-     x509-username-field [ext:]fieldname
+     x509-username-field [ext:]fieldname [[ext:]fieldname...]
 
   Typically, this option is specified with **fieldname** as
   either of the following:
@@ -646,6 +647,7 @@ certificates and keys: https://github.com/OpenVPN/easy-rsa
 
      x509-username-field emailAddress
      x509-username-field ext:subjectAltName
+     x509-username-field CN serialNumber
 
   The first example uses the value of the :code:`emailAddress` attribute
   in the certificate's Subject field as the username. The second example
@@ -653,13 +655,15 @@ certificates and keys: https://github.com/OpenVPN/easy-rsa
   ``fieldname`` :code:`subjectAltName` be searched for an rfc822Name
   (email) field to be used as the username. In cases where there are
   multiple email addresses in :code:`ext:fieldname`, the last occurrence
-  is chosen.
+  is chosen. The last example uses the value of :code:`CN` attribute in
+  the Subject field concatened with :code:`_` delimeter and with the
+  certificate's :code:`serialNumber` as the username.
 
   When this option is used, the ``--verify-x509-name`` option will match
   against the chosen ``fieldname`` instead of the Common Name.
 
   Only the :code:`subjectAltName` and :code:`issuerAltName` X.509
-  extensions are supported.
+  extensions and :code:`serialNumber` X.509 attribute are supported.
 
   **Please note:** This option has a feature which will convert an
   all-lowercase ``fieldname`` to uppercase characters, e.g.,
src/openvpn/init.c +3 -3
index a785934a..fb19fac3 100644
@@ -2905,14 +2905,14 @@ do_init_crypto_tls(struct context *c, const unsigned int flags)
     to.crl_file_inline = options->crl_file_inline;
     to.ssl_flags = options->ssl_flags;
     to.ns_cert_type = options->ns_cert_type;
-    memmove(to.remote_cert_ku, options->remote_cert_ku, sizeof(to.remote_cert_ku));
+    memcpy(to.remote_cert_ku, options->remote_cert_ku, sizeof(to.remote_cert_ku));
     to.remote_cert_eku = options->remote_cert_eku;
     to.verify_hash = options->verify_hash;
     to.verify_hash_algo = options->verify_hash_algo;
 #ifdef ENABLE_X509ALTUSERNAME
-    to.x509_username_field = (char *) options->x509_username_field;
+    memcpy(to.x509_username_field, options->x509_username_field, sizeof(to.x509_username_field));
 #else
-    to.x509_username_field = X509_USERNAME_FIELD_DEFAULT;
+    to.x509_username_field[0] = X509_USERNAME_FIELD_DEFAULT;
 #endif
     to.es = c->c2.es;
     to.net_ctx = &c->net_ctx;
src/openvpn/options.c +26 -23

74 lines not on this page · raw message

src/openvpn/options.h +2 -2
index 877e9396..e527d70e 100644
@@ -584,8 +584,8 @@ struct options
     int handshake_window;
 
 #ifdef ENABLE_X509ALTUSERNAME
-    /* Field used to be the username in X509 cert. */
-    char *x509_username_field;
+    /* Field list used to be the username in X509 cert. */
+    char *x509_username_field[MAX_PARMS];
 #endif
 
     /* Old key allowed to live n seconds after new key goes active */
src/openvpn/ssl_common.h +1 -1
index 96897e48..484bca49 100644
@@ -284,7 +284,7 @@ struct tls_options
     const char *remote_cert_eku;
     uint8_t *verify_hash;
     hash_algo_type verify_hash_algo;
-    char *x509_username_field;
+    char *x509_username_field[MAX_PARMS];
 
     /* allow openvpn config info to be
      * passed over control channel */
src/openvpn/ssl_verify.c +38 -11

64 lines not on this page · raw message

src/openvpn/ssl_verify_openssl.c +14 -0
index 454efeec..9fd3eb50 100644
@@ -269,6 +269,20 @@ backend_x509_get_username(char *common_name, int cn_len,
             return FAILURE;
         }
     }
+    else if (strcmp(LN_serialNumber,x509_username_field) == 0)
+    {
+        ASN1_INTEGER *asn1_i = X509_get_serialNumber(peer_cert);
+        struct gc_arena gc = gc_new();
+        char *serial = format_hex_ex(asn1_i->data, asn1_i->length, 0, 1, NULL, &gc);
+
+        if (!serial || cn_len <= strlen(serial)+2)
+        {
+            gc_free(&gc);
+            return FAILURE;
+        }
+        openvpn_snprintf(common_name, cn_len, "0x%s", serial);
+        gc_free(&gc);
+    }
     else
 #endif
     if (FAILURE == extract_x509_field_ssl(X509_get_subject_name(peer_cert),
Signature · 1 line
2.17.1
#3 lore raw

PATCH v5 1/1 Support X509 field list to be username

OpenVPN has the ability to choose different X509 field in case "CN" can not be use used to be unique connected username since commit 935c62be9c0c8a256112df818bfb8470586a23b6 "Choose a different field in X509 to be username".
Unfortunately it's not enough in case when client has multiple and valid certificates from PKI for different devices (ex. laptop, mobile, etc) with the same CN/UID.

Having --duplicate-cn as a workaround helps only partially: clients can be connected, but it breaks coexistance with --ifconfig-pool-persist, --client-config-dir and opens doors to DoS possibility since same client device (with the same cert) being reconnected no more replaces previously connected session, so it can exhaust server resources (ex. address pool) and can prevent other clients to be connected.

With this patch, multiple X509 fields incl. "serialNumber" can be chosen to be username with --x509-username-field parameters, they will be concatened into the one username using '_' separator. As long as the resulting username is unique, --duplicate-cn will not be required. Default field is preserved as "CN".

Openssl backend is the only supported, since so far MbedTLS has no --x509-username-field support at all.

v2: conform C99, man update, fix typos
v3: reuse buffer methods, drop delimiter define, use memcpy
v4: man update, change separator "_" to avoid path issues on windows
v5: mention collision possibility with "_" separator in man
capitalize hex serialNumber value

---
 doc/man-sections/tls-options.rst | 21 ++++++++++----
 src/openvpn/init.c               |  6 ++--
 src/openvpn/options.c            | 49 +++++++++++++++++---------------
 src/openvpn/options.h            |  4 +--
 src/openvpn/ssl_common.h         |  6 +++-
 src/openvpn/ssl_verify.c         | 49 +++++++++++++++++++++++++-------
 src/openvpn/ssl_verify_openssl.c | 15 ++++++++++
 7 files changed, 104 insertions(+), 46 deletions(-)
doc/man-sections/tls-options.rst +15 -6
index 8c2db7cd..5dd20013 100644
@@ -632,20 +632,23 @@ certificates and keys: https://github.com/OpenVPN/easy-rsa
   options can be defined to track multiple attributes.
 
 --x509-username-field args
-  Field in the X.509 certificate subject to be used as the username
-  (default :code:`CN`).
+  Fields in the X.509 certificate subject to be used as the username
+  (default :code:`CN`). If multiple fields are specified their values
+  will be concatenated into the one username using :code:`_` symbol
+  as a separator.
 
   Valid syntax:
   ::
 
-     x509-username-field [ext:]fieldname
+     x509-username-field [ext:]fieldname [[ext:]fieldname...]
 
-  Typically, this option is specified with **fieldname** as
+  Typically, this option is specified with **fieldname** arguments as
   either of the following:
   ::
 
      x509-username-field emailAddress
      x509-username-field ext:subjectAltName
+     x509-username-field CN serialNumber
 
   The first example uses the value of the :code:`emailAddress` attribute
   in the certificate's Subject field as the username. The second example
@@ -653,16 +656,22 @@ certificates and keys: https://github.com/OpenVPN/easy-rsa
   ``fieldname`` :code:`subjectAltName` be searched for an rfc822Name
   (email) field to be used as the username. In cases where there are
   multiple email addresses in :code:`ext:fieldname`, the last occurrence
-  is chosen.
+  is chosen. The last example uses the value of the :code:`CN` attribute
+  in the Subject field, combined with the :code:`_` separator and the
+  hexadecimal representation of the certificate's :code:`serialNumber`.
 
   When this option is used, the ``--verify-x509-name`` option will match
   against the chosen ``fieldname`` instead of the Common Name.
 
   Only the :code:`subjectAltName` and :code:`issuerAltName` X.509
-  extensions are supported.
+  extensions and :code:`serialNumber` X.509 attribute are supported.
 
   **Please note:** This option has a feature which will convert an
   all-lowercase ``fieldname`` to uppercase characters, e.g.,
   :code:`ou` -> :code:`OU`. A mixed-case ``fieldname`` or one having the
   :code:`ext:` prefix will be left as-is. This automatic upcasing feature is
   deprecated and will be removed in a future release.
+
+  Non-compliant symbols are being replaced with the :code:`_` symbol, same as
+  the field separator, so concatenating multiple fields with such or :code:`_`
+  symbols can potentially lead to username collisions.
src/openvpn/init.c +3 -3
index 31ecadcc..f87c11e7 100644
@@ -2916,14 +2916,14 @@ do_init_crypto_tls(struct context *c, const unsigned int flags)
     to.crl_file_inline = options->crl_file_inline;
     to.ssl_flags = options->ssl_flags;
     to.ns_cert_type = options->ns_cert_type;
-    memmove(to.remote_cert_ku, options->remote_cert_ku, sizeof(to.remote_cert_ku));
+    memcpy(to.remote_cert_ku, options->remote_cert_ku, sizeof(to.remote_cert_ku));
     to.remote_cert_eku = options->remote_cert_eku;
     to.verify_hash = options->verify_hash;
     to.verify_hash_algo = options->verify_hash_algo;
 #ifdef ENABLE_X509ALTUSERNAME
-    to.x509_username_field = (char *) options->x509_username_field;
+    memcpy(to.x509_username_field, options->x509_username_field, sizeof(to.x509_username_field));
 #else
-    to.x509_username_field = X509_USERNAME_FIELD_DEFAULT;
+    to.x509_username_field[0] = X509_USERNAME_FIELD_DEFAULT;
 #endif
     to.es = c->c2.es;
     to.net_ctx = &c->net_ctx;
src/openvpn/options.c +26 -23

74 lines not on this page · raw message

src/openvpn/options.h +2 -2
index 877e9396..e527d70e 100644
@@ -584,8 +584,8 @@ struct options
     int handshake_window;
 
 #ifdef ENABLE_X509ALTUSERNAME
-    /* Field used to be the username in X509 cert. */
-    char *x509_username_field;
+    /* Field list used to be the username in X509 cert. */
+    char *x509_username_field[MAX_PARMS];
 #endif
 
     /* Old key allowed to live n seconds after new key goes active */
src/openvpn/ssl_common.h +5 -1
index 96897e48..53f74cac 100644
@@ -284,7 +284,11 @@ struct tls_options
     const char *remote_cert_eku;
     uint8_t *verify_hash;
     hash_algo_type verify_hash_algo;
-    char *x509_username_field;
+#ifdef ENABLE_X509ALTUSERNAME
+    char *x509_username_field[MAX_PARMS];
+#else
+    char *x509_username_field[2];
+#endif
 
     /* allow openvpn config info to be
      * passed over control channel */
src/openvpn/ssl_verify.c +38 -11

64 lines not on this page · raw message

src/openvpn/ssl_verify_openssl.c +15 -0
index 454efeec..34e1de01 100644
@@ -269,6 +269,21 @@ backend_x509_get_username(char *common_name, int cn_len,
             return FAILURE;
         }
     }
+    else if (strcmp(LN_serialNumber,x509_username_field) == 0)
+    {
+        ASN1_INTEGER *asn1_i = X509_get_serialNumber(peer_cert);
+        struct gc_arena gc = gc_new();
+        char *serial = format_hex_ex(asn1_i->data, asn1_i->length,
+                                     0, 1 | FHE_CAPS, NULL, &gc);
+
+        if (!serial || cn_len <= strlen(serial)+2)
+        {
+            gc_free(&gc);
+            return FAILURE;
+        }
+        openvpn_snprintf(common_name, cn_len, "0x%s", serial);
+        gc_free(&gc);
+    }
     else
 #endif
     if (FAILURE == extract_x509_field_ssl(X509_get_subject_name(peer_cert),
Signature · 1 line
2.17.1
Acked-by on v5 1/1
#4 lore raw

Re: [Openvpn-devel] [PATCH v5] Support X509 field list to be username

Am 05.10.20 um 02:51 schrieb Vladislav Grishenko:

Quoted 35 lines

OpenVPN has the ability to choose different X509 field in case "CN" can not be use used to be unique connected username since commit 935c62be9c0c8a256112df818bfb8470586a23b6 "Choose a different field in X509 to be username".
Unfortunately it's not enough in case when client has multiple and valid certificates from PKI for different devices (ex. laptop, mobile, etc) with the same CN/UID.

Having --duplicate-cn as a workaround helps only partially: clients can be connected, but it breaks coexistance with --ifconfig-pool-persist, --client-config-dir and opens doors to DoS possibility since same client device (with the same cert) being reconnected no more replaces previously connected session, so it can exhaust server resources (ex. address pool) and can prevent other clients to be connected.

With this patch, multiple X509 fields incl. "serialNumber" can be chosen to be username with --x509-username-field parameters, they will be concatened into the one username using '_' separator. As long as the resulting username is unique, --duplicate-cn will not be required. Default field is preserved as "CN".

Openssl backend is the only supported, since so far MbedTLS has no --x509-username-field support at all.

v2: conform C99, man update, fix typos
v3: reuse buffer methods, drop delimiter define, use memcpy
v4: man update, change separator "_" to avoid path issues on windows
v5: mention collision possibility with "_" separator in man
capitalize hex serialNumber value

src/openvpn/ssl_verify_openssl.c +0 -0
index 454efeec..34e1de01 100644

src/openvpn/ssl_verify_openssl.c backend_x509_get_username(char *common_name, int cn_len, · line 273

Quoted 5 lines
src/openvpn/ssl_verify_openssl.c +2 -0
@@ -269,6 +269,21 @@ backend_x509_get_username(char *common_name, int cn_len,
             return FAILURE;
         }
     }
+    else if (strcmp(LN_serialNumber,x509_username_field) == 0)
+    {

Whitespace error after ,

Otherwise the patch looks good now. (We had informal reviews on IRC that prompted the newer versions)

#5 lore raw

Re: [Openvpn-devel] [PATCH v5] Support X509 field list to be username

Hi Arne,

Quoted 41 lines

From: Arne Schwabe
Sent: Monday, October 5, 2020 1:26 PM
Am 05.10.20 um 02:51 schrieb Vladislav Grishenko:

Quoted 8 lines

OpenVPN has the ability to choose different X509 field in case "CN" can not be use used to be unique connected username since commit 935c62be9c0c8a256112df818bfb8470586a23b6 "Choose a different field in X509 to be username".
Unfortunately it's not enough in case when client has multiple and valid certificates from PKI for different devices (ex. laptop, mobile, etc) with the same CN/UID.

Quoted 6 lines

Having --duplicate-cn as a workaround helps only partially: clients can be connected, but it breaks coexistance with --ifconfig-pool-persist, --client-config-dir and opens doors to DoS possibility since same client device (with the same cert) being reconnected no more replaces previously connected session, so it can exhaust server resources (ex. address pool) and can prevent other clients to be

connected.

src/openvpn/ssl_verify_openssl.c backend_x509_get_username(char *common_name,

Quoted 22 lines

With this patch, multiple X509 fields incl. "serialNumber" can be chosen to be username with --x509-username-field parameters, they will be concatened into the one username using '_' separator. As long as the resulting username is unique, --duplicate-cn will not be required. Default field is preserved as "CN".

Openssl backend is the only supported, since so far MbedTLS has no --x509-username-field support at all.

v2: conform C99, man update, fix typos
v3: reuse buffer methods, drop delimiter define, use memcpy
v4: man update, change separator "_" to avoid path issues on windows
v5: mention collision possibility with "_" separator in man
capitalize hex serialNumber value

src/openvpn/ssl_verify_openssl.c +0 -0
index 454efeec..34e1de01 100644
@@ -269,6 +269,21 @@ backend_x509_get_username(char *common_name,

int cn_len,

Quoted 7 lines

src/openvpn/ssl_verify_openssl.c backend_x509_get_username(char *common_name, int cn_len, · line 273

Quoted 5 lines
src/openvpn/ssl_verify_openssl.c +2 -0
             return FAILURE;
         }
     }
+    else if (strcmp(LN_serialNumber,x509_username_field) == 0)
+    {

Whitespace error after ,

Style copy-paste from the line above, will fix both places in v6 version. Thanks
https://github.com/OpenVPN/openvpn/blob/master/src/openvpn/ssl_verify_openssl.c#L265

Quoted 5 lines

Otherwise the patch looks good now. (We had informal reviews on IRC that prompted the newer versions)

--
Best Regards, Vladislav Grishenko

#6 lore raw

[Openvpn-devel] [PATCH applied] Re: Support X509 field list to be username

In reply to Vladislav Grishenko

Your patch has been applied to the master branch.

Client-side tested, and lightly stared at the code.

The whitespace dragon made me add that blank after comma (but not the other one in code not already touched by this patch) - IRC discussion points to "sp_after_comma", which we indeed do not set today. We need to discuss this with the dragons :-)

After quite some deliberation I've decided that this is "new feature" and "too late for 2.5", so not applied to release/2.5 - it was not an easy decision, as this could indeed be a very useful feature for server operators running "distribution provided" binaries, which usually is "2.5". OTOH, at some point we want to get 2.5.0 *out*, and if we keep adding features, we need more RCs, and then we'll never get there. OTOH, again, this is a fairly isolated change - so if enough users yell at me that THEY MUST HAVE THIS, we could put it in 2.5.1 or 2.5.2 ("small and isolated new features can be done in small-numbered subreleases").

Also, we do want 2.6.0 to happen "soonish" this time, like "in one year, not in four years". Let's see...

commit 3b04c34de140355b5b1d4ed85f7ccf1db9b0135d

Author: Vladislav Grishenko
Date:   Mon Oct 5 05:51:14 2020 +0500
     Support X509 field list to be username

     Signed-off-by: Vladislav Grishenko <[email protected]...>
     Acked-by: Arne Schwabe <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg21168.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#7 lore raw

Re: [Openvpn-devel] [PATCH applied] Re: Support X509 field list to be username

Hi Gert,
Thank you.

--
Best Regards, Vladislav Grishenko

Quoted 7 lines

-----Original Message-----
From: Gert Doering <[email protected]...>
Sent: Monday, October 5, 2020 3:36 PM
To: Vladislav Grishenko <[email protected]...>
Cc: [email protected]
Subject: [PATCH applied] Re: Support X509 field list to be username

Quoted 5 lines

Your patch has been applied to the master branch.

Client-side tested, and lightly stared at the code.

The whitespace dragon made me add that blank after comma (but not the

other

Quoted 2 lines

one in code not already touched by this patch) - IRC discussion points to "sp_after_comma", which we indeed do not set today. We need to discuss

this

Quoted 5 lines

with the dragons :-)

After quite some deliberation I've decided that this is "new feature" and "too late for 2.5", so not applied to release/2.5 - it was not an easy decision, as this could indeed be a very useful feature for server

operators

Quoted 1 line

running "distribution provided" binaries, which usually is "2.5". OTOH,

at some

Quoted 1 line

point we want to get 2.5.0 *out*, and if we keep adding features, we need

more

Quoted 1 line

RCs, and then we'll never get there. OTOH, again, this is a fairly

isolated change

Quoted 1 line

- so if enough users yell at me that THEY MUST HAVE THIS, we could put it

in

Quoted 1 line

2.5.1 or 2.5.2 ("small and isolated new features can be done in

small-numbered

Quoted 3 lines

subreleases").

Also, we do want 2.6.0 to happen "soonish" this time, like "in one year,

not in

Quoted 20 lines

four years". Let's see...

commit 3b04c34de140355b5b1d4ed85f7ccf1db9b0135d

Author: Vladislav Grishenko
Date:   Mon Oct 5 05:51:14 2020 +0500
     Support X509 field list to be username

     Signed-off-by: Vladislav Grishenko <[email protected]...>
     Acked-by: Arne Schwabe <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/openvpn-
[email protected]/msg21168.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#8 lore raw

Re: [Openvpn-devel] [PATCH applied] Re: Support X509 field list to be username

In reply to Gert Doering
Quoted 10 lines · Gert Doering

After quite some deliberation I've decided that this is "new feature" and "too late for 2.5", so not applied to release/2.5 - it was not an easy decision, as this could indeed be a very useful feature for server operators running "distribution provided" binaries, which usually is "2.5". OTOH, at some point we want to get 2.5.0 *out*, and if we keep adding features, we need more RCs, and then we'll never get there. OTOH, again, this is a fairly isolated change - so if enough users yell at me that THEY MUST HAVE THIS, we could put it in 2.5.1 or 2.5.2 ("small and isolated new features can be done in small-numbered subreleases").

I agree, this is not 2.5 stuff. If it is not a new feature, it is at least a feature extension - not a bug, security or stability fix which is what we should focus on now in the 2.5_rc phase.

Quoted 2 lines

Also, we do want 2.6.0 to happen "soonish" this time, like "in one year, not in four years". Let's see...

Yeah, lets get 2.6 out sooner - with lesser new features on the plate, and rather save some goodies for post 2.6 releases - to help the overall development/release cycles go faster.

Signature · 4 lines
kind regards,

David Sommerseth
OpenVPN Inc