From 3accb244e95fcf9b4b9098440e3dda06534c6e3f Mon Sep 17 00:00:00 2001 From: chubtub <43381989+chubtub@users.noreply.github.com> Date: Thu, 10 Jun 2021 12:34:38 -0400 Subject: [PATCH] Catch DecoderException in the tcg_rim_tool CredentialParser class. --- .../tcg_rim_tool/src/main/java/hirs/swid/CredentialParser.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/tcg_rim_tool/src/main/java/hirs/swid/CredentialParser.java b/tools/tcg_rim_tool/src/main/java/hirs/swid/CredentialParser.java index 0defcb80..9f24ace0 100644 --- a/tools/tcg_rim_tool/src/main/java/hirs/swid/CredentialParser.java +++ b/tools/tcg_rim_tool/src/main/java/hirs/swid/CredentialParser.java @@ -10,6 +10,7 @@ import org.bouncycastle.openssl.PEMKeyPair; import org.bouncycastle.openssl.PEMParser; import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter; import org.bouncycastle.util.encoders.Base64; +import org.bouncycastle.util.encoders.DecoderException; import java.io.*; import java.security.*; @@ -154,6 +155,8 @@ public class CredentialParser { } } catch (FileNotFoundException e) { System.out.println("Unable to locate private key file: " + filename); + } catch (DecoderException e) { + System.out.println("Failed to parse uploaded pem file: " + e.getMessage()); } catch (NoSuchAlgorithmException e) { System.out.println("Unable to instantiate KeyFactory with algorithm: " + algorithm); } catch (IOException e) {