### Question:
SslInfoImpl implements SslInfo { @Nullable @Override public X509Certificate[] getPeerCertificates() { Certificate[] certificates; try { certificates = session.getPeerCertificates(); } catch (Throwable ex) { return null; } List<X509Certificate> result = new ArrayList<>(certificates.length); for (Certificate certificate : certificates) { if (certificate instanceof X509Certificate) { result.add((X509Certificate) certificate); } } return (!result.isEmpty() ? result.toArray(new X509Certificate[0]) : null); } SslInfoImpl(SSLSession session); @Nullable @Override String getSessionId(); @Nullable @Override X509Certificate[] getPeerCertificates();  }### Answer:
@Test public void shouldHandleSSLPeerUnverifiedException() throws SSLPeerUnverifiedException { given(mockSession.getPeerCertificates()).willThrow(SSLPeerUnverifiedException.class); assertThat(sslInfo.getPeerCertificates()).isNull(); }
@Test public void shouldGetX509Certificates() throws SSLPeerUnverifiedException { given(mockSession.getPeerCertificates()).willReturn(new Certificate[]{ mockCertificate, mockX509Certificate }); assertThat(sslInfo.getPeerCertificates()).containsOnly(mockX509Certificate); }
@Test public void shouldNotGetX509Certificates() throws SSLPeerUnverifiedException { given(mockSession.getPeerCertificates()).willReturn(new Certificate[]{ mockCertificate }); assertThat(sslInfo.getPeerCertificates()).isNull(); }