setup
Initializes the TrustPin SDK with the specified configuration.
This suspend method configures TrustPin with your organization credentials and fetches the pinning configuration from the TrustPin service. The configuration is cached for 10 minutes to optimize performance and reduce network requests.
Example Usage
// Production setup with strict mode
suspend fun initializeTrustPin() {
TrustPin.setup(
organizationId = "prod-org-123",
projectId = "mobile-app-v2",
publicKey = "LS0tLS1CRUdJTi...",
mode = TrustPinMode.STRICT
)
}
// Development setup with permissive mode
suspend fun initializeForDevelopment() {
TrustPin.setup(
organizationId = "dev-org-456",
projectId = "mobile-app-staging",
publicKey = "LS0tLS1CRUdJTk...",
mode = TrustPinMode.PERMISSIVE
)
}Security Considerations
Production: Always use TrustPinMode.STRICT mode to ensure all connections are validated
Development: Use TrustPinMode.PERMISSIVE mode to allow connections to unregistered domains
Credentials: Keep your public key secure and never commit it to version control in plain text
Network Requirements
This method requires network access to fetch the pinning configuration from https://cdn.trustpin.cloud. Ensure your app has appropriate network permissions and can reach this endpoint.
Parameters
Your organization identifier from the TrustPin dashboard
Your project identifier from the TrustPin dashboard
Base64-encoded public key for signature verification
The pinning mode controlling behavior for unregistered domains (default: TrustPinMode.STRICT)
Throws
if credentials are invalid or empty
if network request fails
if signature verification fails
Initializes the TrustPin SDK with a custom configuration URL.
This suspend method allows developers to override the default TrustPin configuration URL with a custom full URL for the signed payload. This is useful for custom deployment scenarios or when using alternative configuration endpoints.
Example Usage
// Custom configuration URL setup
suspend fun initializeWithCustomURL() {
TrustPin.setup(
organizationId = "your-org-id",
projectId = "your-project-id",
publicKey = "LS0tLS1CRUdJTi...",
configurationURL = URI.create("https://custom.example.com/config/signed-payload.b64").toURL(),
mode = TrustPinMode.STRICT
)
}Security Considerations
Ensure the custom URL serves a valid signed payload
The payload must be signed with the same public key provided
Use HTTPS URLs to maintain security during configuration retrieval
Parameters
Your organization identifier from the TrustPin dashboard
Your project identifier from the TrustPin dashboard
Base64-encoded public key for signature verification
Custom URL for the signed payload. CDN Managed project should not use this method.
The pinning mode controlling behavior for unregistered domains (default: TrustPinMode.STRICT)
Throws
if credentials are invalid or empty
if network request fails
if signature verification fails