Skip to content

KeychainStore Ignored Exception on macOS #53

Description

@charphi

Describe the bug
On macOS, a KeychainStore exception is printed on the error stream instead of being logged or thrown. This exception happens when a certificate provided by the system has multiple "X509v3 Extended Key Usage" sections.

To Reproduce

  1. On macOS, load any system certificate that has duplicate extensions
  2. The following text should be printed on the err stream of the command line :
    KeychainStore Ignored Exception: java.security.cert.CertificateParsingException: java.io.IOException: Duplicate extensions not allowed

Expected behavior
The system should not print the error instead of logging it, expecially for command line apps.

Environmental Data:

  • Any Java Version
  • Any Maven Version
  • MacOS

Additional context
The faulty code is available on openjdk repository at
https://github.com/openjdk/jdk16/blob/020ec8485251698d1187204ac13321f4726e45ea/src/java.base/macosx/classes/apple/security/KeychainStore.java#L810
https://github.com/openjdk/jdk16/blob/37043b05576c8b81b43ac41a8f06de0d0bbb3f5b/src/java.base/share/classes/sun/security/x509/CertificateExtensions.java#L105

I've written a quick and dirty workaround that decorate the err stream to log the exception instead of printing it.

My question is: is there a better solution?

Activity

  1. Hakky54 commented on Jan 21, 2021

    @Hakky54
    Owner

    Hi Philippe,

    It is a bit sad that the developers of the jdk have decided tot print this message to the console. But I think it is more a design decision as they don't want to rely on external libraries such as slf4j. But they still could have used the java.util.logging instead of printing it in the console, so I am not sure why they decided to do it like this. Maybe you can raise a bug/issue on their jira page and suggest that they use java util logging, see here: https://bugs.openjdk.java.net/secure/Dashboard.jspa Or you can even create a pull request on their github page: https://github.com/openjdk/jdk

    Your workaround looks fine to me, you extend the PrintStream with some custom logic. And for a specific use case you delegate the print statement to the logger 👍🏼

  2. charphi commented on Jan 26, 2021

    @charphi
    Author

    Thanks.

    The problem is not as big as I first thought.
    The messages are printed on the error stream, not the output stream.
    So, it is annoying but it doesn't prevent the command line tool to do its job.

  3. Hakky54 commented on Jan 26, 2021

    @Hakky54
    Owner

    Aha great to hear, I also don't think it would harm but indeed it can be a bit annoying.
    Good luck, please let me know if you have any other questions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions