How to verify signature on self signed jar?

…衆ロ難τιáo~ 提交于 2019-12-04 10:46:21

The JarFile class embeds the jar verifier. This code snippet verifies the signature of all entries in an archive :

JarFile jar = new JarFile("/path/to/myarchive.jar");
Enumeration<JarEntry> entries = jar.entries();
while (entries.hasMoreElements()) {
    JarEntry entry = entries.nextElement();
    try {
        jar.getInputStream(entry);
    } catch (SecurityException se) {
        /* Incorrect signature */
        throw new Error("Signature verification failed", se);
    }
}

Note that this code verifies the integrity of the jar but does not verifies the signature against a given key or certificate.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!