easy-rsa icon indicating copy to clipboard operation
easy-rsa copied to clipboard

Any magic about the 64 bytes common-name length limit

Open ihipop opened this issue 2 years ago • 13 comments

Since I have read about the RFC3280: https://www.ietf.org/rfc/rfc3280.html#:~:text=ub-common-name-length%20integer%20%3A%3A%3D RFC5280: https://www.ietf.org/rfc/rfc5280.html#:~:text=ub-common-name-length%20integer%20%3A%3A%3D and related https://github.com/notaryproject/notary/issues/914

And if I issue a certificate with a common name longer than 64 bytes, easy-rsa will fail with an error

Using Easy-RSA 'vars' configuration:
* /home/*****/CA/vars

Using SSL:
* openssl OpenSSL 3.2.1 30 Jan 2024 (Library: OpenSSL 3.2.1 30 Jan 2024)
-----
String too long, must be at most 64 bytes long
Error making certificate request

Easy-RSA error:

easyrsa_openssl - Command has failed:
* openssl req -utf8 -new -newkey ec:/home/*****/CA/pki/15b9edd6/temp.1.1 -keyout /home/*****/CA/pki/15b9edd6/temp.2.1 -out /home/*****/CA/pki/15b9edd6/temp.3.1 -noenc -batch

EasyRSA Version Information
Version:     3.1.7
Generated:   Fri Oct 13 17:27:51 CDT 2023
SSL Lib:     OpenSSL 3.2.1 30 Jan 2024 (Library: OpenSSL 3.2.1 30 Jan 2024)
Git Commit:  3c233d279d43e419b0529411ee62bba7a08f0c0f
Source Repo: https://github.com/OpenVPN/easy-rsa
Host: 3.1.7 | nix | Linux | /bin/bash

WARNING
=======
cleanup - remove_secure_session failed

but your CloudConnexa of OpenVPN allows a common name to exceed 64 bytes

image

Is there any magic in easy-rsa ?

ihipop avatar Mar 20 '24 03:03 ihipop

I've tried to change the

EASYRSA_DN to cn_only

then change the commonName_max of cn_only to 128 in openssl-easyrsa.cnf still,the error exists:


Using SSL:
* openssl OpenSSL 3.2.1 30 Jan 2024 (Library: OpenSSL 3.2.1 30 Jan 2024)
-----
Error making certificate request
4077017C547F0000:error:06800097:asn1 encoding routines:ASN1_mbstring_ncopy:string too long:crypto/asn1/a_mbstr.c:106:maxsize=64

ihipop avatar Mar 20 '24 09:03 ihipop

Also, try changing easyrsa:6242:

commonName_max		= 64

TinCanTech avatar Mar 20 '24 14:03 TinCanTech

Also, try changing easyrsa:6242:

commonName_max		= 64

have you tried? I can't make it work

ihipop avatar Mar 20 '24 14:03 ihipop

The max appears to be 64.

TinCanTech avatar Mar 20 '24 18:03 TinCanTech

your CloudConnexa of OpenVPN allows a common name to longer than 64 bytes

ihipop avatar Mar 21 '24 01:03 ihipop

The EasyRSA commonName 64 character limit is sufficient for sensible requirements.

TinCanTech avatar Mar 21 '24 01:03 TinCanTech

Taking ASCII characters 0-9 and a-z gives a naming pool of:

36^64 = 4×10⁹⁹

More than enough.

TinCanTech avatar Mar 21 '24 01:03 TinCanTech

Taking ASCII characters 0-9 and a-z gives a naming pool of:

36^64 = 4×10⁹⁹

More than enough.

@TinCanTech

If you use OpenVPN web auth, you will find out that every device has a device ID in the form of UUID, which is 36 bytes long

to distinguish every device with different devices with different common name, usually an enterprise email address is prefixed as a part of a common name, Just like what CloudConnexa of OpenVPN does. for example

[email protected]/2BB779C3-7765-46AA-9EB2-8E9BFC0500D8

tata, exceed 64bytes~

ihipop avatar Mar 21 '24 01:03 ihipop

CloudConnexa obviously have their own solution.

TinCanTech avatar Mar 21 '24 02:03 TinCanTech

Happened to me today. I had a automation setup to create clients with naming convention <full_name_serverid_dateTimestamp>. For long names, this exceeds 64 bytes and I was wondering what is causing my invalid .ovpn files.

rbnhd avatar Jul 09 '25 07:07 rbnhd

@rbnhd

<full_name_serverid_dateTimestamp>.

Please give an example.

TinCanTech avatar Jul 09 '25 11:07 TinCanTech

@TinCanTech I have installed openVPN server following this script: https://github.com/angristan/openvpn-install/

How to reproduce:

$ ./openvpn-install.sh

  • Chose Add a client. Prompts for client name.
  • enter a client name longer than 64 bytes. ex: reallylongFname_MiddleName_longLastname_mylinuxhost001_20250709_185345. (I use headless User addition btw, the script runs automatically and at first I was confused why are my users getting invalid .ovpn files)
  • The script will succeed. The .ovpn file will be generated without any error.
  • BUT, if you cat the .ovpn file, you will notice that it's an invalid file which can't be imported to OpenVPN client app.
Easy-RSA/OpenSSL silently truncates or rejects Common Names longer than ≈64 bytes – the generated client certificate fails, leaving your .ovpn with empty <cert>/<key> sections.

rbnhd avatar Jul 10 '25 01:07 rbnhd

$ easyrsa --nopass --req-cn="12345678901234567890123456789012345678901234567890123456789012345" build-client-full f1
Using Easy-RSA 'vars' configuration:
* /home/tct/git/easy-rsa/test/installed/test D/pki/vars
Generating a RSA private key
.............................................+++++
.......................................................................................................+++++
writing new private key to '/home/tct/git/easy-rsa/test/installed/test D/pki/302e9e5b/temp.03'
-----
problems making Certificate Request
140118838424896:error:0D07A097:asn1 encoding routines:ASN1_mbstring_ncopy:string too long:../crypto/asn1/a_mbstr.c:107:maxsize=64

Easy-RSA error:

TinCanTech avatar Jul 10 '25 02:07 TinCanTech