create
Creates a new context-aware TrustPinSSLSocketFactory with TrustPin integration.
This factory method creates an SSLSocketFactory that includes TrustPin certificate validation with explicit hostname context. The factory automatically selects the best available trust manager implementation based on JVM capabilities.
Automatic Trust Manager Selection:
ExtendedTrustPinManager: Used when X509ExtendedTrustManager is available (Java 7+, Android API 24+)
Better SNI support
Automatic hostname extraction from Socket/SSLEngine
Enhanced TLS compatibility
TrustPinTrustManager: Used as fallback on older platforms
Reliable basic functionality
Compatible with all Java/Android versions
Security Features:
Context-aware validation eliminates race conditions
No thread-local storage reduces memory attack surface
Whitelisted system trust manager detection prevents injection
Explicit hostname binding prevents validation bypass
Implementation details hidden in internal classes for obfuscation
Example:
val sslSocketFactory = TrustPinSSLSocketFactory.create()
HttpsURLConnection.setDefaultSSLSocketFactory(sslSocketFactory)Return
A new context-aware TrustPinSSLSocketFactory instance
Throws
if SSL context creation fails
if security validation fails