-
Notifications
You must be signed in to change notification settings - Fork 420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set the string-mask to utf8only #115
Conversation
If subject had utf-8 characters in them, the encoding chosen by OpenSSL for defaults T61. From the OpenSSL source code: * utf8only : only use UTF8Strings (RFC2459 recommendation for 2004). That was 10 years ago, and the last remnant that had problems with it was Netscape, which is no longer a problem. A request changes from: 13:d=5 hl=2 l= 3 prim: OBJECT :commonName 18:d=5 hl=2 l= 9 prim: T61STRING :Gurka ��� To: 13:d=5 hl=2 l= 3 prim: OBJECT :commonName 18:d=5 hl=2 l= 12 prim: UTF8STRING :Gurka åäö OpenSSL/test/test_crypto.py Update test DER data to have utf8string. ( \x0c instead of \0x13, PrintableString )
As you noted in pyca/cryptography#1088, the call to I am a bit concerned about this patch because it makes the assumption that UTF8String is equally compatible with PrintableString, et al. Looking more closely at
I'd suggest that we err on the side of caution and have anything that's representable by PrintableString remain PrintableString and only use UTF8String when the character set requires it. Hypothetically it seems like |
I agree on the global one, but I'm not sure where to put global library instantiations. Regarding PrintableString, I'm not sure it's a good default really, quoting RFC5280:
The exceptions mentioned are relevant, and declare that if issuer is in T61 or BMPString, Subject must be in the same encoding. Further the RFC states:
Also, further down:
Also! The current state in OpenSSL upstream is to have openssl.cnf declare "string_mask = utf8only" by default. This has also been the default since 2005 ( upstream commit id 29b9763d) So, this is why I'm suggesting the current change to PyOpenSSL. It would bring the defaults in line with how upstream has done it for the last 9 years. |
Looking at upstreams:
|
I suspect @exarkun has an opinion on where global settings should live :) Thanks for the info about when OpenSSL changed this default in their conf (openssl/openssl@29b9763d is the link to the commit). Looks like it's a safe default then, especially given the RHEL/CentOS information. I suppose if we want to be very conservative we could do |
What's causing these changes right now is that we're working with a CA that's rejecting anything pyOpenSSL creates due to this. |
Looking further, it seems as if there's some initialization done in crypto.py at the end ( OpenSSL_add_all_algorithms() and SSL_load_error_strings() ) Should this go at the same place? |
Yes, that's a good place for it to be. Would |
0x2002 ought to work as a default, though we'd want an override. It's not a good form to mix printable string types, especially not when subject / issuer / subjectKeyIdentifier contain different string types. |
Nothing in x509 is good form. 😢 |
ASN.1, let me count the ways I hate you. I'm hoping that we can migrate to SSH tunnels and OpenSSH certificate formats. At least it's sane. |
…me time as other code.
Updated commit. moves the initialization to the end of crypto.py, but keeps utf8only. Sidenote, how should the dependency on cryptography look? >= 0.5? Or should I simply test for existance of the function first? |
That's ultimately going to be @exarkun's call. My own opinion would be make the dependency >=0.5 so there's no ambiguity over what PyOpenSSL is doing with ASN.1 string types based on what version of cryptography the user may have installed. |
I'd be inclined to agree, as it also changes the DER encoded strings in the testcases from T.61 to utf8. ( Those were already ASCII, so it's weird that they aren't PrintableStrings to begin with ) |
Well, until the cryptography things are either released, or I push an alternative URI in the setup.py, I guess the travis changes will fail. You're the maintainers, so I'll defer to your good judgement! Signing off for today! |
Just a head's up about defaults, LibreSSL has changed the default //D.S. On Sat, May 31, 2014 at 6:47 PM, Paul Kehrer [email protected]
|
And another fix on this, OpenSSL upstream has now changed the default of //D.S. On Sat, May 31, 2014 at 6:47 PM, Paul Kehrer [email protected]
|
Note OpenSSL changing the default (openssl/openssl@3009244 present in openssl 1.0.1h) causes test_der to fail. I filed duplicate issue #129 about that. Applying the changes suggested on this issue would fix that, and make pyopenssl behave consistently again independently of the openssl version it is using. |
This has been rebased and is in #234. |
If subject had utf-8 characters in them, the encoding chosen by OpenSSL for
defaults T61.
Requires changes in cryptography, commit id f8561cdf06f163806a57b0dd36290192414e3496
From the OpenSSL source code:
* utf8only : only use UTF8Strings (RFC2459 recommendation for 2004).
That was 10 years ago, and the last remnant that had problems with it
was Netscape, which is no longer a problem.
A request changes from:
13:d=5 hl=2 l= 3 prim: OBJECT :commonName
18:d=5 hl=2 l= 9 prim: T61STRING :Gurka ���
To:
13:d=5 hl=2 l= 3 prim: OBJECT :commonName
18:d=5 hl=2 l= 12 prim: UTF8STRING :Gurka åäö
OpenSSL/test/test_crypto.py
Update test DER data to have utf8string.
( \x0c instead of \0x13, PrintableString )