Skip to content

Commit 097a707

Browse files
committed
wrap native wolfSSL_CertManagerUnloadCAs()
1 parent 14cfe03 commit 097a707

3 files changed

Lines changed: 38 additions & 0 deletions

File tree

native/com_wolfssl_WolfSSLCertManager.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,22 @@ JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSLCertManager_CertManagerLoadCABuff
103103
return (jint)ret;
104104
}
105105

106+
JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSLCertManager_CertManagerUnloadCAs
107+
(JNIEnv* jenv, jclass jcl, jlong cmPtr)
108+
{
109+
int ret = 0;
110+
WOLFSSL_CERT_MANAGER* cm = (WOLFSSL_CERT_MANAGER*)(uintptr_t)cmPtr;
111+
(void)jcl;
112+
113+
if (jenv == NULL) {
114+
return BAD_FUNC_ARG;
115+
}
116+
117+
ret = wolfSSL_CertManagerUnloadCAs(cm);
118+
119+
return (jint)ret;
120+
}
121+
106122
JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSLCertManager_CertManagerVerifyBuffer
107123
(JNIEnv* jenv, jclass jcl, jlong cmPtr, jbyteArray in, jlong sz, jint format)
108124
{

native/com_wolfssl_WolfSSLCertManager.h

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/java/com/wolfssl/WolfSSLCertManager.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public class WolfSSLCertManager {
4545
static native int CertManagerLoadCA(long cm, String f, String d);
4646
static native int CertManagerLoadCABuffer(long cm, byte[] in, long sz,
4747
int format);
48+
static native int CertManagerUnloadCAs(long cm);
4849
static native int CertManagerVerifyBuffer(long cm, byte[] in, long sz,
4950
int format);
5051

@@ -150,6 +151,19 @@ public int CertManagerLoadCAKeyStore(KeyStore ks) throws WolfSSLException {
150151
}
151152
}
152153

154+
/**
155+
* Unload any CAs that have been loaded into WolfSSLCertManager object.
156+
*
157+
* @return WolfSSL.SSL_SUCCESS on success, negative on error.
158+
*/
159+
public int CertManagerUnloadCAs() {
160+
if (this.active == false) {
161+
throw new IllegalStateException("Object has been freed");
162+
}
163+
164+
return CertManagerUnloadCAs(this.cmPtr);
165+
}
166+
153167
/**
154168
* Verify X.509 certificate held in byte array
155169
*

0 commit comments

Comments
 (0)