public static boolean verifyOcspCertificates ( BasicOCSPResp ocsp , KeyStore keystore , String provider ) { if ( provider == null ) provider = "BC" ; try { for ( Enumeration aliases = keystore . aliases ( ) ; aliases . hasMoreElements ( ) ; ) { try { String alias = ( String ) aliases . nextElement ( ) ; if ( ! keystore . isCertificateEntry ( alias ) ) continue ; X509Certificate certStoreX509 = ( X509Certificate ) keystore . getCertificate ( alias ) ; if ( ocsp . isSignatureValid ( new JcaContentVerifierProviderBuilder ( ) . setProvider ( provider ) . build ( certStoreX509 . getPublicKey ( ) ) ) ) return true ; } catch ( Exception ex ) { } } } catch ( Exception e ) { } return false ; }
Verifies an OCSP response against a KeyStore .