Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion native/com_wolfssl_WolfSSLX509StoreCtx.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ JNIEXPORT jobjectArray JNICALL Java_com_wolfssl_WolfSSLX509StoreCtx_X509_1STORE_
}
XMEMCPY(buf, der, derSz);
(*jenv)->ReleaseByteArrayElements(jenv, derArr, buf, 0);
(*jenv)->SetObjectArrayElement(jenv, certArr, i, derArr);
/* Reverse order, so peer cert is first in returned array,
* followed by intermediates, lastly by root. Native
* wolfSSL_X509_STORE_GetCerts() returns certs in order of
* root to peer, but Java/JSSE expects peer to root */
(*jenv)->SetObjectArrayElement(jenv, certArr, skNum-1-i, derArr);
Comment thread
cconlon marked this conversation as resolved.
(*jenv)->DeleteLocalRef(jenv, derArr);
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/java/com/wolfssl/WolfSSLX509StoreCtx.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ private synchronized void confirmObjectIsActive()
* Get certificates in WOLFSSL_X509_STORE_CTX as an array of
* WolfSSLCertificate objects.
*
* The certificate chain is returned in order of peer to root, with peer
* first, then any intermediates, then root last (if present).
*
* @return array of certificates
* @throws WolfSSLException on error
* @throws IllegalStateException if object has been freed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ public int verifyCallback(int preverify_ok, long x509StorePtr) {
}

try {
/* get WolfSSLCertificate[] from x509StorePtr */
/* Get WolfSSLCertificate[] from x509StorePtr, certs from
* store.getCerts() should be listed in order of peer to root */
WolfSSLX509StoreCtx store =
new WolfSSLX509StoreCtx(x509StorePtr);
certs = store.getCerts();
Expand Down
Loading