Skip to contentSkip to conversation

Bug: extended x509-username-field broken in git

Openvpn-devel Markus Kötter 4 participants 7 messages Jul 5, 2011 – Jul 8, 2011

lore
Share & tools
lore
#0 lore raw

Hi,

"x509-username-field ext:altSubjectName"

does not work on current git - the X509 cert passed to extract_x509_extension [1] simply lacks the extension. The nid for altSubjectName is retrieved correctly (85), but the call to X509_get_ext_d2i simply returns no matching extension.

I've had this working with 2.2-beta3 using the patch sent to this ml.
Additionally to testing git, I took the debian 2.2.0 packages (I know they add some patches, but nothing which should interfere here), added the patch from openvpn git [2], and it did not work either.

The clients openvpn version never changed, so thats not a problem, I confirmed the altSubjectNames data is transfered on the wire nevertheless.

I had a look on the diff for 2.2-beta3 to 2.2.0 and saw no suspicious changes - maybe because I just don't know how one would suppress the extensions from being accessible in the certificate.

So for now I have to use 2.2-beta3.

Suggestions?

Markus

[1] http://openvpn.git.sourceforge.net/git/gitweb.cgi?p=openvpn/openvpn.git;a=blobdiff;f=ssl.c;h=7b2291c6b3bd86a62ca02830e3fdf3c6f1ac310a;hp=ed107148146a77226df4c60c8e4094da0739ae71;hb=3fa86d237721ca113fa020b7e888a1e10374a560;hpb=338b6948dd52bc0cf2da7e09a29f5127066a7af7

[2] http://openvpn.git.sourceforge.net/git/gitweb.cgi?p=openvpn/openvpn.git;a=commit;h=3fa86d237721ca113fa020b7e888a1e10374a560

#1 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 1 line · Markus Kötter

Hi,

[...snip...]

Quoted 8 lines

I had a look on the diff for 2.2-beta3 to 2.2.0 and saw no suspicious changes - maybe because I just don't know how one would suppress the extensions from being accessible in the certificate.

So for now I have to use 2.2-beta3.

Suggestions?

Can you please use git bisect to locate the offending commit?

   $ git bisect start v2.2.0 v2.2-beta3

then you build and try to run your test routine. If this worked, then you do:

  $ git bisect good

Or if it failed, then you do:

  $ git bisect bad

Do this good/bad thing until git have located the commit which changes the behaviour. You will get a result similar to what you see here:
<https://community.openvpn.net/openvpn/ticket/108#comment:1>

kind regards,

David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAk4TDoUACgkQDC186MBRfrqczgCfTnHHJTyFgHWwqhrG7+9DcDVQ uWwAn2zUHMQSrwnIvT+fgXpzaEveuppk
=7juI
-----END PGP SIGNATURE-----

#2 lore raw
Quoted 1 line · David Sommerseth

Can you please use git bisect to locate the offending commit?

I figured out this never really worked with openvpn git at all. During discussing the patch, the check for the error_depth disappeared. So, if the root certificate lacked the extension, it would fail.

Therefore, attached a patch which accepts this kind of error if the error_depth is != 0 - the lowest level of the cert is not reached yet. This duplicates the behavior which is used for the fields.

I was wondering why the script tries to extract values from certificates for any level but 0 anyway?

MfG
Markus

ssl.c +5 -2
index a0493ff..48c6be1 100644
@@ -977,12 +977,15 @@ verify_callback (int preverify_ok, X509_STORE_CTX * ctx)
     {
       if (!extract_x509_extension (ctx->current_cert, x509_username_field+4, common_name, sizeof(common_name)))
         {
-          msg (D_TLS_ERRORS, "VERIFY ERROR: could not extract %s extension from X509 subject string ('%s') "
+          if (!ctx->error_depth)
+            {
+              msg (D_TLS_ERRORS, "VERIFY ERROR: could not extract %s extension from X509 subject string ('%s') "
                              "-- note that the username length is limited to %d characters",
                              x509_username_field+4,
                              subject,
                              TLS_USERNAME_LEN);
-          goto err;
+              goto err;
+            }
         }
     } else
 #endif
#3 lore raw
Quoted 9 lines · Markus Koetter
Quoted 2 lines · David Sommerseth

Can you please use git bisect to locate the offending commit?

I figured out this never really worked with openvpn git at all. During discussing the patch, the check for the error_depth disappeared. So, if the root certificate lacked the extension, it would fail.

Quoted 7 lines

Therefore, attached a patch which accepts this kind of error if the error_depth is != 0 - the lowest level of the cert is not reached yet. This duplicates the behavior which is used for the fields.

I was wondering why the script tries to extract values from certificates for any level but 0 anyway?

Hi Markus,

A fix is included in my SSL separation patch set, in this patch to be exact:
https://github.com/andj/openvpn-ssl-refactoring/commit/71e27b1e282bf8e10724b69fe4cbeac65dee325b
.

Does that solve the problem?

Adriaan

#5 lore raw
Quoted 7 lines

-----Original Message-----
From: Markus Kötter [mailto:[email protected]...]

Quoted 3 lines · Adriaan de Jong

A fix is included in my SSL separation patch set, in this patch to be exact:
https://github.com/andj/openvpn-ssl-

Quoted 8 lines

refactoring/commit/71e27b1e282bf8e10724b69fe4cbeac65dee325b .

Quoted 3 lines

Does that solve the problem?

The logic should be fixed yes.
Remaining question is why does openvpn even try to retrieve values from upper cert layers - they'll be overwritten anyway.

The information is provided to scripts and plugins in environment variables, so that additional verification can be performed there.

Regards,
Adriaan

#6 lore raw
Quoted 6 lines · Adriaan de Jong
Quoted 4 lines

-----Original Message-----
From: Markus Kötter [mailto:[email protected]...]
Remaining question is why does openvpn even try to retrieve values from upper cert layers - they'll be overwritten anyway.

The information is provided to scripts and plugins in environment variables, so that additional verification can be performed there.

Maybe we got a misunderstanding:

Question is what would be wrong with:

if( !cert_depth && verify_get_username(..) )
err();

Markus