Merge pull request #204 from jackctj117/fix-getLocalPrincipal

Changed getLocalPrincipal to assume user cert is first in chain
pull/201/head
Chris Conlon 2024-06-17 11:56:44 -06:00 committed by GitHub
commit 910b6124f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 9 deletions

View File

@ -647,7 +647,7 @@ public class WolfSSLImplementSSLSession extends ExtendedSSLSession
@Override
public Principal getLocalPrincipal() {
/* Logic needs to be added to check for client auth when wrapper is made TODO */
X509KeyManager km = authStore.getX509KeyManager();
java.security.cert.X509Certificate[] certs =
km.getCertificateChain(authStore.getCertAlias());
@ -657,12 +657,9 @@ public class WolfSSLImplementSSLSession extends ExtendedSSLSession
return null;
}
for (int i = 0; i < certs.length; i++) {
if (certs[i].getBasicConstraints() < 0) {
/* is not a CA treat as end of chain */
localPrincipal = certs[i].getSubjectDN();
break;
}
if (certs.length > 0){
/* When chain of certificates exceeds one, the user certifcate is the first */
localPrincipal = certs[0].getSubjectDN();
}
/* free native resources earlier than garbage collection if

View File

@ -120,9 +120,10 @@ public class WolfSSLSessionTest {
/* test certificates */
System.out.print("\tTesting session cert");
session = client.getSession();
if (session.getLocalPrincipal() != null) {
/* TODO changes back to != null once we can check for client auth */
if (session.getLocalPrincipal() == null) {
error("\t... failed");
fail("found unexpected principal");
fail("Principal is null when it should not be");
}
try {