Skip to content
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

Use consistently SHA-256 for signatures (possible fix for issue #1992) #1999

Closed
wants to merge 3 commits into from

Conversation

gganis
Copy link
Member

@gganis gganis commented Apr 16, 2023

On systems honouring, by default, the deprecation of SHA1, such as AlmaLinux 9, xrdgsiproxy fails (see issue #1992).
This patch replaces use of SHA1 by SHA-256 for signatures. SHA-256 is supported by all OpenSSL versions still around,
which makes it easier from point of view of portability. Move to SHA3 should be considered for the future.

@@ -455,7 +455,7 @@ int XrdCryptosslX509CreateProxy(const char *fnc, const char *fnk,
}
//
// Sign the request
if (!(X509_REQ_sign(preq, ekPX, EVP_sha1()))) {
if (!(X509_REQ_sign(preq, ekPX, EVP_sha256()))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this could/should be made configurable by the user.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it certainly can ..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At run time or build time?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think run time would be better, but I'd like to hear what @abh thinks about it too. If SHA-256 works everywhere and is relatively future-proof, we could just switch the default and still leave it hard-coded.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But also, why not SHA3 now? Old OpenSSL won't support it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have a look at the revised patch

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Yes, SHA3 is not supported by the OpenSSL's around - introduced in 1.1.1 - so to force it requires some additional checks ... SHA-256 is present in all the versions still around).

Default is SHA-256. The SHA funtion is controlled by name
by the env var XrdCryptoGSISHA .
@abh3
Copy link
Member

abh3 commented Apr 17, 2023 via email

static const EVP_MD *sslSHAFun = 0;
if (!sslSHAFun) {
const char *_md = getenv("XrdCryptoGSISHA") ? getenv("XrdCryptoGSISHA") : "sha256";
sslSHAFun = EVP_get_digestbyname(_md);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the user passes a bad name, this will assign nullptr to sslSHAFun, which will probably cause trouble. We need to check that we get a non-null pointer from EVP_get_digestbyname and fallback to the default otherwise.

I was also thinking that if the only place where this is needed is in xrdgsiproxy, we could add an option on the command line, like -sig sha256 which would use a different signature than the default, but that can be done later.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so to make it cleaner I close this PR and make another one only with the initial changes, not to pollute the history.

@amadio
Copy link
Member

amadio commented Apr 17, 2023

Ok, let's go for the initial change to just replace sha1 with sha256 then. I still like the idea of providing a -sig command line option in xrdgsiproxy, as that would let people use sha3 now if they wanted. Maybe I will add that later.

@gganis
Copy link
Member Author

gganis commented Apr 17, 2023

Closing to rebase and make it cleaner

@gganis gganis closed this Apr 17, 2023
@gganis gganis deleted the fix-1992 branch April 17, 2023 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants