Skip to content

Commit

Permalink
Removed debug logs for invalid der certificate
Browse files Browse the repository at this point in the history
  • Loading branch information
Hakky54 committed May 6, 2024
1 parent 494d678 commit 10d831a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
import nl.altindag.ssl.exception.GenericCertificateException;
import nl.altindag.ssl.exception.GenericIOException;
import nl.altindag.ssl.util.internal.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.net.ssl.X509TrustManager;
import javax.security.auth.x500.X500Principal;
Expand Down Expand Up @@ -69,8 +67,6 @@
*/
public final class CertificateUtils {

private static final Logger LOGGER = LoggerFactory.getLogger(CertificateUtils.class);

private static final String CERTIFICATE_TYPE = "X.509";
private static final String P7B_HEADER = "-----BEGIN PKCS7-----";
private static final String P7B_FOOTER = "-----END PKCS7-----";
Expand Down Expand Up @@ -257,7 +253,6 @@ public static List<Certificate> parseDerCertificate(InputStream certificateStrea
.generateCertificates(bufferedCertificateStream).stream()
.collect(toUnmodifiableList());
} catch (CertificateException | IOException e) {
LOGGER.debug("There is no valid certificate present to parse. Please make sure to supply a valid der formatted certificate", e);
return Collections.emptyList();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package nl.altindag.ssl.util;

import nl.altindag.log.LogCaptor;
import nl.altindag.ssl.TestConstants;
import nl.altindag.ssl.exception.GenericCertificateException;
import nl.altindag.ssl.exception.GenericIOException;
Expand Down Expand Up @@ -643,13 +642,11 @@ void throwsGenericIOExceptionWhenCloseOfTheStreamFails() throws IOException {
}

@Test
void generateDebugMessageWhenUnsupportedDataIsProvided() throws IOException {
try(LogCaptor logCaptor = LogCaptor.forClass(CertificateUtils.class);
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream("Hello".getBytes())) {
void returnEmptyListOfCertificatesWhenUnsupportedDataIsProvided() throws IOException {
try(ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream("Hello".getBytes())) {
List<Certificate> certificates = CertificateUtils.parseDerCertificate(byteArrayInputStream);

assertThat(certificates).isEmpty();
assertThat(logCaptor.getDebugLogs()).contains("There is no valid certificate present to parse. Please make sure to supply a valid der formatted certificate");
}
}

Expand Down

0 comments on commit 10d831a

Please sign in to comment.