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

Feat: improve SSL error logging/unwrapping #178

Merged
merged 7 commits into from
Jun 17, 2021

Conversation

kares
Copy link
Contributor

@kares kares commented Jun 15, 2021

To be able to easily log full Java SSL exception details, we first move the SSL builder to Java.

otherwise this is ~ same as logstash-plugins/logstash-input-beats#405 :

The unwrapping at the Java level is for exceptions wrapped by Netty.

Full exception details will be logged at debug level from the Java side - since we seem to prefer (manual) exception logging at the plugin level. We also make sure to log cause, if any, on the Ruby side which now catches all (expected) Java exceptions.

NOTE: we also avoid installing the bouncy-castle security provider at runtime, done previously

resolves #177

Copy link
Contributor

@robbavey robbavey left a comment

Choose a reason for hiding this comment

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

minor debug logging question, otherwise LGTM

} catch (CertificateException ex) {
Throwable cause = ex.getCause();
if (cause != null && "Empty input".equals(cause.getMessage())) {
continue;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a case for debug or trace logging upon receiving this error, or is it always benign?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good call, I simply converted from the .rb parts and did not revisit with potential logging.
the whole logic seems a bit unusual - would rather just use generateCertificates to read multiple entries.
anyhow, let's keep that as before and I am going to add a debug line around the caught "empty" exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added debug logging + an extra check when expecting to read at least one certificate from ssl_cert
also worth noting (in the changelog) we no longer have the side effect of setting up the BC provider globally.

@kares kares requested a review from robbavey June 16, 2021 05:52
Copy link
Contributor

@robbavey robbavey left a comment

Choose a reason for hiding this comment

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

LGTM

@kares kares merged commit cf4b821 into logstash-plugins:master Jun 17, 2021
kares added a commit that referenced this pull request Aug 25, 2021
With the Ruby -> Java rewrite in #178 we avoided installing the BC provider at runtime.
Unfortunately to be able to decrypt some openssl keys the BC class relies on the fact that the provider is available.

Otherwise reading the key leads to a `PBKDF-OpenSSL SecretKeyFactory not available`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

improve error logging to always reveal SSL details
4 participants