开发者

Problem retrieving certificates for self signed jar

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜