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

Improvements to ssl-keystore parameter #824

Merged
merged 7 commits into from
Jan 20, 2025

Conversation

eduardomozart
Copy link
Contributor

@eduardomozart eduardomozart commented Jan 17, 2025

Add SystemRootCA for macOS and support other OSes to Mozilla:CA in ssl-keystore. This also adds support for using certs from /etc/ssl/certs (Unix/Linux systems like Debian).

As discussed in #823, this PR adds the SystemRootCA for macOS and remove the ssl-keystore limitation on other systems as they could rely at least on Mozilla CA store.

…l-keystore

As discussed in glpi-project#823, this PR adds the SystemRootCA for macOS and remove the ``ssl-keystore`` limitation on other systems as they could rely at least on Mozilla CA store.
@eduardomozart eduardomozart changed the title Add SystemRootCA for macOS and support other OSes to Mozilla:CA in ss… Improvements to ssl-keystore parameter Jan 17, 2025
Copy link
Member

@g-bougard g-bougard left a comment

Choose a reason for hiding this comment

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

Hi @eduardomozart

I'm not agree to enable "ssl-keystore" for other OS as I explain below in my comments.

I would prefer also to change the behavior of system public CA loading for MacOS so it has to be clearly chosen by the user. You (and people) should consider this other command run as time consuming and this is probably not a good thing in most cases.

lib/GLPI/Agent/HTTP/Client.pm Show resolved Hide resolved
Comment on lines 607 to 611
getAllLines(
command => "security find-certificate -a -p /System/Library/Keychains/SystemRootCertificates.keychain >> '$file'",
logger => $logger
);
push @certs, IO::Socket::SSL::Utils::PEM_file2certs($file)
Copy link
Member

@g-bougard g-bougard Jan 17, 2025

Choose a reason for hiding this comment

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

That was not my idea.

I prefer to change the command on a given "ssl-keystore" value.

Here you force the run of 2 commands where this is not required for most people as Mozilla::CA should provide the public CA certificates.

I would prefer something like:

my $command = "security find-certificate -a -p";
$command .= " /System/Library/Keychains/SystemRootCertificates.keychain"
    if $self->{ssl_keystore} =~ /^system-ssl-ca$/i;
getAllLines(
     command => "$command > '$file'",
     logger  => $logger
);

and even, on l.695, the test on Mozilla::CA should be changed to not load it if system public ca are used as this would be redundant:

if (($OSNAME ne 'darwin' || $self->{ssl_keystore} !~ /^system-ssl-ca$/i) && Mozilla::CA->require()) {

Copy link
Contributor Author

@eduardomozart eduardomozart Jan 17, 2025

Choose a reason for hiding this comment

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

The Mozilla CA may not include self-signed CA certs available on system store. I updated the macOS code to meet your expectations, but I still believe the system root CA store should be loaded instead of the current user (root) as it's useless since it contains only Apple CA's - I know the default CA store from the user can be changed but most users won't do that.
I updated the code to load Mozilla::CA only if @certs is empty (it means it didn't load the CAs from third party cert stores) or if it's macOS and user didn't provided the 'system-root-ca' parameter.

Comment on lines +695 to +701
# Like Mozilla::CA, but using certs from /etc/ssl/certs
if ($OSNAME !~ /^darwin|MSWin32$/) {
my $sslcacert = "/etc/ssl/certs/ca-certificates.crt";
push @certs, IO::Socket::SSL::Utils::PEM_file2certs($sslcacert)
if -e $sslcacert;
}

Copy link
Member

Choose a reason for hiding this comment

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

As I said on my first comment, this is not required as this is still the default.

Copy link
Contributor Author

@eduardomozart eduardomozart Jan 17, 2025

Choose a reason for hiding this comment

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

I believe there should be cases where internal CA is used and some automation tool already added the self-signed certificate to system CA store and it's not a public certificate provided by Mozilla::CA. As this use case is supported on Windows and macOS (otherwise it wouldn't need to import the keystore/keychain from those systems), I don't see why don't include support for keystore of other systems too, only if the SSL library loads it by default?

@g-bougard
Copy link
Member

I would prefer also to change the behavior of system public CA loading for MacOS so it has to be clearly chosen by the user. You (and people) should consider this other command run as time consuming and this is probably not a good thing in most cases.

To complete my comment, I think this case should only be used if people are in the case glpi server certificate public CA is not available in Mozilla::CA but it is in system public CA. And this should only happen in really rare cases.

@g-bougard g-bougard merged commit 501857a into glpi-project:develop Jan 20, 2025
16 checks passed
@g-bougard
Copy link
Member

Hi @eduardomozart

as I'm about to make a new release in the next few days, I preferred to merge manually your PR removing no more required changes.

For me, on MacOSX, the keychain default support permits people to install glpi server certificate in the safe keychain of root user. Even if most people won't do that, this is a feature they can easily use.

Now, the "ssl-keystore=system-ssl-ca" option is a security for users: Actually Mozilla::CA is updated during releases, but in the case the project dies in a far future, using this option may help people to continue using glpi-agent with server installed with SSL signed by a public CA not known at the time of glpi-agent release.

@eduardomozart
Copy link
Contributor Author

eduardomozart commented Jan 20, 2025

That's great!
I updated the ssl-keystore documentation to describe this new behavior, please let me know if I'm right: glpi-project/doc-agent#11

@eduardomozart
Copy link
Contributor Author

It's a bit sad that the support for extracting CA trust store hasn't been approved for Unix/Linux and it relies only on Mozilla:CA since, as you'd said, if someday the GLPI-Agent dies and embedded Mozilla::CA becomes old, or if the user uses a self-signed CA imported to CA trust store, it will not be trusted by default.

@g-bougard
Copy link
Member

g-bougard commented Jan 21, 2025

ca-cert-file, ca-cert-dir and ssl-fingerprint were there before ssl-keystore and will always be there to help people with such a problem. You can use these options to trust a certificate which is not known from the embedded Mozilla::CA.

@eduardomozart
Copy link
Contributor Author

ca-cert-file, ca-cert-dir and ssl-fingerprint were there before ssl-keystore and will always be there to help people with such a problem. You can use these options to trust a certificate which is not known from the embedded Mozilla::CA.

Yes, I know, but it requires manual intervention, while ssl-keystore works on-the-fly. If the certificate expires (e.g. Let's Encrypt), it requires updating the signature. Also, some software antivirus like ESET intercepts the SSL connection using it own self-signed certificate to SSL inspection, and it requires creating a manual exception to exclude the GLPI server address from inspection if GLPI-Agent uses a SSL connection.

@g-bougard
Copy link
Member

I'm not agree with you. "ssl-keystore" feature would also require a manual intervention in that hypothetical case. Adding an overload charging more certificates where this is not required most of the time and for most users was not an option.
And sorry, your comment on ESET is totally out of scope.

@eduardomozart
Copy link
Contributor Author

I'm not agree with you. "ssl-keystore" feature would also require a manual intervention in that hypothetical case. Adding an overload charging more certificates where this is not required most of the time and for most users was not an option. And sorry, your comment on ESET is totally out of scope.

It depends. If it's the Let's Encrypt CA, it's updated by updating the package ca-certificates which keep the OpenSSL CA trust store always updated without relying on GLPI-Agent updates so GLPI-Agent would keep working forever even if GLPI-Agent is long gone and built-in Mozilla::CA isn't updated. The ssl-fingerprint is useless for Let's Encrypt certificates since every 3 months the GLPI server certificate is updated, which makes it useless, and ca-cert-file and ca-cert-dir requires manual creation. I believe that ssl-fingerprint would be more useful if it applies to Root CA thumbprint since renewing the Root CA certificate doesn't affect it's thumbprint (aka. make ssl-fingerprint validates every thumbprint on the certificate chain, not only the server certificate), so even if the server certificate is changed, if the Root CA is still the same (even if renewed, since thumbprint of Root CA certificates isn't changed when it's renewed and auto-renew is enable for Windows ADCS self-signed Enterprise CA), the GLPI-Agent will continue to function forever.
Also, I'm not sure how GLPI-Agent behavior when the GLPI server-certificate expires - does it relies only on thumbprint or there's some internal SSL function which is triggered to allow/not allow connection on those cases?
About the ESET, it may also affect other products, like Sophos Firewall/FortiGate that does SSL inspection on the edge of the network, which replaces the GLPI server certificate with it's own during GLPI-Agent connection and GLPI-Agent connection fails. If Unix/Linux provides a trust store that could be extracted and used instead of relying on Mozilla::CA, I don't see why not use it, and use Mozilla::CA on last case. Some of these scenarios are not atypical at all - ESET, Kaspersky and other AV solutions (e.g. which could be installed on a endpoint of an user that works HomeOffice) does SSL interception, and the import of Windows keystore makes the GLPI-Agent works on-the-fly on Windows and macOS machines only, excluding Unix/Linux users.

@g-bougard
Copy link
Member

Hi @eduardomozart

sorry, but PR comments thread is not a forum.

The PR has been merged manually with some changes, end of the discussion.

If you need to discuss on a point, please open a new discussion.

@glpi-project glpi-project locked as off-topic and limited conversation to collaborators Jan 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants