From dfc438f6189de272f2c8464b692fdd05aa49bfcb Mon Sep 17 00:00:00 2001 From: Jairo Grateron Date: Thu, 11 Apr 2024 11:33:51 -0400 Subject: [PATCH] fix NPE examine crt from url --- .../gui/actions/ExamineClipboardAction.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/kse/src/main/java/org/kse/gui/actions/ExamineClipboardAction.java b/kse/src/main/java/org/kse/gui/actions/ExamineClipboardAction.java index 2f019505a..ea3143b59 100644 --- a/kse/src/main/java/org/kse/gui/actions/ExamineClipboardAction.java +++ b/kse/src/main/java/org/kse/gui/actions/ExamineClipboardAction.java @@ -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); }