diff --git a/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/CertificateUtil.java b/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/CertificateUtil.java index 1ca59aee05..cf17aca15c 100644 --- a/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/CertificateUtil.java +++ b/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/CertificateUtil.java @@ -19,6 +19,7 @@ import java.io.ByteArrayInputStream; import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.security.PublicKey; import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; @@ -45,7 +46,7 @@ public static RSAPublicKey parseRSAPublicKey(String pem) throws ServletException try { CertificateFactory fact = CertificateFactory.getInstance("X.509"); ByteArrayInputStream is = new ByteArrayInputStream( - fullPem.getBytes("UTF8")); + fullPem.getBytes(StandardCharsets.UTF_8)); X509Certificate cer = (X509Certificate) fact.generateCertificate(is); key = cer.getPublicKey(); @@ -58,8 +59,6 @@ public static RSAPublicKey parseRSAPublicKey(String pem) throws ServletException message = "CertificateException - PEM may be corrupt"; } throw new ServletException(message, ce); - } catch (UnsupportedEncodingException uee) { - throw new ServletException(uee); } return (RSAPublicKey) key; }