Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
decodeCertificate throws IllegalArgumentException on an unparseable certificate #16
The org.cryptacular.util.CertUtil.decodeCertificate(byte) method catches the Java runtime's CertificateException when there's a problem parsing a certificate, and turns it into an IllegalArgumentException. That obviously isn't declared on the method since it's a runtime exception, so we weren't catching that in our X509Support class in OpenSAML.
I'd say as a general matter the parsing oriented methods ought to avoid throwing runtime errors since those are certainly likely to show up at runtime through no fault of the code.
Fixed in the context of pull request #22. It's worth noting that I didn't take the "no runtime exception" route because it would have had dramatic consequences on the API. Instead, I took care to declare specific subclasses of RuntimeException that are well documented and declared on the throws clause to help emphasize what exceptions can be emitted from various method calls. Then implementers have the choice of handling them or not based on their specific needs. The PR has further justification for handling all API-specific errors as runtime exceptions.