I have a jar that's self signed with keys that I generated using the java keytool. At runtime I attempt to retrieve the certificates with the following code:
ProtectionDomain pd = MyApplication.class.getProtectionDomain();
Certificate[] cert = pd.getCodeSource().getCertificates();
This works fine when my jar is used in a standalone, command line java application. However, when I use this jar in a web application that's deployed in Weblogic server, the getCertificates() call retu开发者_运维问答rns null. Why?
Because the container has been configured to unzip the .WAR file, so it is loading your classes from the WEB-INF/classes directory instead of the .WAR file directly. So the code source is a directory so it doesn't have a certificate.
精彩评论