java jni openssl nginx证书私钥有效性校验
1、安装openssl
wget https://www.openssl.org/source/openssl-1.1.1b.tar.gz
./config –prefix=/usr/local/openssl –shared
–shared为添加动态库,生成libssl.so,默认只有libssl.a静态库
make
make install
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
cp /usr/local/openssl/lib/openssl/libssl.so.1.1 /lib/x86_64-linux-gnu/
cp /usr/local/openssl/lib/openssl/libcrypto.so.1.1 /lib/x86_64-linux-gnu/
2、新建jni工程(eclipse为例)
新建java工程PemCheck
src下新建class com.jni.OpenSSLUtils.java
package com.jni; public class OpenSSLUtils { public native static int checkPem(String pem,String key); }