public class PemUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static String |
cleanUpPem(String pem)
Cleanup Function that removes most formatting and copy/paste mistakes from
PEM formatted Strings.
|
static String |
removeInvalidPemChars(String pem)
Removes characters that are not valid in PEM format (non-base64 chars).
|
static boolean |
safeSanityCheck(String pem,
int maxChainLength,
String expectedPemTypeSubString)
Returns false if there is a problem with a PEM instead of throwing an
Exception.
|
static void |
sanityCheck(String pem,
int maxChainLength,
String expectedPemTypeSubString)
Performs various sanity checks on a PEM Formatted String, and should be
tolerant of common minor mistakes in formatting.
|
public static String removeInvalidPemChars(String pem)
pem - The input "dirty" PEMpublic static String cleanUpPem(String pem)
pem - The input "dirty" PEMpublic static void sanityCheck(String pem, int maxChainLength, String expectedPemTypeSubString)
pem - The PEM or PEM Chain to validate.maxChainLength - The max number of PEM encoded objects in the
String.expectedPemTypeSubString - A Substring that is expected to be present in
the PEM Type.IllegalArgumentException - if there is a problem with the PEM formatted
String.public static boolean safeSanityCheck(String pem, int maxChainLength, String expectedPemTypeSubString)
pem - The PEM to sanity check.maxChainLength - The Max number of PEM Objects in the PEM
StringexpectedPemTypeSubString - A Substring that is expected to be present in
the PEM Type.Copyright © 2019. All rights reserved.