verifyBlocking

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

domain

The domain name to validate (e.g., "api.example.com")

certificate

X.509 certificate object to verify

Throws

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