Skip to content

Commit

Permalink
fix NPE examine crt from url
Browse files Browse the repository at this point in the history
  • Loading branch information
jgrateron committed Apr 11, 2024
1 parent c77cd82 commit dfc438f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions kse/src/main/java/org/kse/gui/actions/ExamineClipboardAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,19 +240,19 @@ private void downloadCrl(URL url) throws IOException, CryptoException {
}

private void downloadCert(URL url) throws IOException, CryptoException {
HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
int status = urlConn.getResponseCode();
if (isRedirect(status)) {
String newUrl = urlConn.getHeaderField("Location");
url = new URL(newUrl);
urlConn = (HttpURLConnection) url.openConnection();
}
HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
int status = urlConn.getResponseCode();
if (isRedirect(status)) {
String newUrl = urlConn.getHeaderField("Location");
url = new URL(newUrl);
urlConn = (HttpURLConnection) url.openConnection();
}
try (InputStream is = urlConn.getInputStream()) {
X509Certificate[] certs = X509CertUtil.loadCertificates(IOUtils.toByteArray(is));
if (certs != null && certs.length > 0) {
DViewCertificate dViewCertificate = new DViewCertificate(frame, MessageFormat.format(
resExt.getString("DViewExtensions.ViewCert.Title"), url.toString()), certs, null,
DViewCertificate.NONE);
DViewCertificate dViewCertificate = new DViewCertificate(frame,
MessageFormat.format(resExt.getString("DViewExtensions.ViewCert.Title"), url.toString()), certs,
this.kseFrame, DViewCertificate.NONE);
dViewCertificate.setLocationRelativeTo(frame);
dViewCertificate.setVisible(true);
}
Expand Down

0 comments on commit dfc438f

Please sign in to comment.