开发者

Problem retrieving certificates for self signed jar

开发者 https://www.devze.com 2023-02-10 16:19 出处:网络
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:

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

精彩评论

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

关注公众号