Merge pull request #204 from jackctj117/fix-getLocalPrincipal
Changed getLocalPrincipal to assume user cert is first in chainpull/201/head
commit
910b6124f4
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue