Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed getLocalPrincipal to assume user cert is first in chain #204

Merged
merged 3 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ public synchronized Principal getPeerPrincipal()

@Override
public Principal getLocalPrincipal() {

/* Logic needs to be added to check for client auth when wrapper is made TODO */
cconlon marked this conversation as resolved.
Show resolved Hide resolved
X509KeyManager km = authStore.getX509KeyManager();
java.security.cert.X509Certificate[] certs =
km.getCertificateChain(authStore.getCertAlias());
Expand All @@ -657,12 +657,9 @@ public Principal getLocalPrincipal() {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,10 @@ public void testSessionTimeAndCerts() {
/* 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 {
Expand Down