verify Blocking
Verifies a certificate against the specified domain using public key pinning (blocking version).
⚠️ WARNING: This method blocks the calling thread
This blocking method is provided for Java interoperability and non-coroutine contexts. It MUST NOT be called from:
Android main/UI thread (will cause ANR)
Any coroutine context (use suspend verify function instead)
Recommended Alternatives:
// ✅ RECOMMENDED: Kotlin with coroutines
lifecycleScope.launch {
try {
TrustPin.verify("api.example.com", certificate)
println("Certificate is valid!")
} catch (e: TrustPinError) {
println("Verification failed: ${e.message}")
}
}
// ✅ Java with ExecutorService
executor.execute(() -> {
try {
TrustPin.verifyBlocking("api.example.com", certificate);
System.out.println("Certificate is valid!");
} catch (TrustPinError e) {
System.err.println("Verification failed: " + e.getMessage());
}
});Parameters
The domain name to validate (e.g., "api.example.com")
X.509 certificate object to verify
Throws
if setup has not been called
if configuration cannot be fetched from CDN
if certificate cannot be parsed
if certificate doesn't match any configured pins
if all configured pins have expired
if signature validation fails
if domain is not configured (strict mode only)
if called from Android main thread