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

Modified HttpClient.java to pick token details correctly if admin/age… #223

Open
wants to merge 2 commits into
base: DOGTAG_10_5_BRANCH
Choose a base branch
from
Open
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion base/java-tools/src/com/netscape/cmstools/HttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public void send(String ifilename, String ofilename, String tokenName, String db
certname.append(":");
}
certname.append(nickname);
System.out.println("Certificate Nickname:" + " " + certname);

X509Certificate cert =
cm.findCertByNickname(certname.toString());
Expand All @@ -152,7 +153,8 @@ public void send(String ifilename, String ofilename, String tokenName, String db
else
System.out.println("client cert is not null");
sslSocket.setUseClientMode(true);
sslSocket.setClientCertNickname(nickname);
String certnick = certname.toString();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

functionally looks good, but for cleanliness, see how "certname.toString()" is used at line 148 too? How about move this (line 156) up above that (line 148) and change the reference of "certname.toString()" to "certnick" as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ladycfu .
How about this:

                sslSocket.setUseClientMode(true);
                sslSocket.setClientCertNickname(certname.toString());
                X509Certificate cert =
                    cm.findCertByNickname(certname.toString());

                if (cert == null)
                    System.out.println("client cert is null");
                else
                    System.out.println("client cert is not null");

Copy link
Contributor

@ladycfu ladycfu Jun 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I meant was:
String certnick = certname.toString();
X509Certificate cert =
cm.findCertByNickname(certnick);
if (cert == null)
System.out.println("client cert is null");
else
System.out.println("client cert is not null");
sslSocket.setUseClientMode(true);
sslSocket.setClientCertNickname(certnick);

sslSocket.setClientCertNickname(certnick);
}

sslSocket.forceHandshake();
Expand Down