@SuppressWarnings("unchecked")
    private static byte[] getOcspDataFromSession(SSLSession session) {
        List<byte[]> ocspResponses = null;
        if (session instanceof ConscryptSession) {
            ConscryptSession opensslSession = (ConscryptSession) session;
            ocspResponses = opensslSession.getStatusResponses();
        } else {
            Method m_getResponses;
            try {
                m_getResponses = session.getClass().getDeclaredMethod("getStatusResponses");
                m_getResponses.setAccessible(true);
                Object rawResponses = m_getResponses.invoke(session);
                if (rawResponses instanceof List) {
                    ocspResponses = (List<byte[]>) rawResponses;
                }
            } catch (NoSuchMethodException | SecurityException
                    | IllegalAccessException | IllegalArgumentException ignored) {
                // Method not available, fall through and return null
            } catch (InvocationTargetException e) {
                throw new RuntimeException(e.getCause());
            }
        }

        if (ocspResponses == null || ocspResponses.isEmpty()) {
            return null;
        }

        return ocspResponses.get(0);
    }
Validates whether a server is trusted. If session is given and non-null
it also checks if chain is pinned appropriately for that peer host. If
null, it does not check for pinned certs. The return value is a list of
the certificates used for making the trust decision.
common/src/main/java/org/conscrypt/TrustManagerImpl.java