我有一个pkcs12文件.我需要使用它来使用https协议连接到网页.我遇到了一些代码,为了连接到安全的网页,我需要设置以下系统属性:
System.setProperty("javax.net.ssl.trustStore", "myTrustStore");
System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
System.setProperty("javax.net.ssl.keyStoreType", "pkcs12");
System.setProperty("javax.net.ssl.keyStore", "new_cert.p12");
System.setProperty("javax.net.ssl.keyStorePassword", "newpass");
Run Code Online (Sandbox Code Playgroud)
我有p12(pkcs12)文件.我只需要一个信任库文件.
我使用以下方法提取证书:
openssl.exe pkcs12 -in c:/mykey.p12 -out c:/cert.txt -nokeys -clcerts
Run Code Online (Sandbox Code Playgroud)
现在将证书PEM文件转换为der
openssl.exe x509 -in c:/cert.txt -outform DER -out c:/CAcert.der
Run Code Online (Sandbox Code Playgroud)
现在将der文件添加到密钥库
keytool -import -file C:/Cacert.der -keystore mytruststore
Run Code Online (Sandbox Code Playgroud)
现在我有了信任库,但是当我使用它时,我收到以下错误
Exception in thread "main" java.net.SocketException: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl)
Run Code Online (Sandbox Code Playgroud)
更新:删除某些属性并仅设置"trustStore","trustStorePassword"和"trustStoreType"属性后,我得到以下异常
java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
Run Code Online (Sandbox Code Playgroud)
请帮忙.
我正在声明一个void指针数组.每个都指向任意类型的值.
void **values; // Array of void pointers to each value of arbitary type
初始化值如下:
values = (void**)calloc(3,sizeof(void*));
//can initialize values as: values = new void* [3];
int ival = 1;
float fval = 2.0;
char* str = "word";
values[0] = (void*)new int(ival);
values[1] = (void*)new float(fval);
values[2] = (void*)str;
//Trying to Clear the memory allocated
free(*values);
//Error: *** glibc detected *** simpleSQL: free(): invalid pointer: 0x080611b4
//Core dumped
delete[] values*;
//warning: deleting 'void*' is undefined
//Similar Error.
Run Code Online (Sandbox Code Playgroud)
现在我如何释放/删除为值分配的内存(void指针数组)?