SDK Quickstart
This guide shows you how to build a simple application using the OpenTDF SDKs to encrypt and decrypt data. You'll create a lightweight client that connects to your local OpenTDF platform and demonstrates the core SDK functionality.
Complete the Getting Started guide first to set up your local OpenTDF platform. This quickstart assumes:
- Platform running at
https://platform.opentdf.local:8443 - Keycloak running at
https://keycloak.opentdf.local:9443 - Client credentials:
opentdf/secret
This quickstart takes 15-20 minutes to complete.
What You'll Build
A simple application that:
- Connects to your local OpenTDF platform
- Authenticates using client credentials
- Encrypts sensitive data into a TDF file
- Decrypts the TDF file back to plaintext
Choose Your SDK
OpenTDF provides native SDKs in three languages. Choose your language to get started with complete, working examples:
Go SDK
Native Go library with excellent performance for backend services and CLI tools.
Java SDK
Full-featured Java library for enterprise applications and Android development.
JavaScript/TypeScript SDK
Modern SDK for Node.js and browser applications with TypeScript support.
Key Concepts
Client Credentials Authentication
All three SDKs use client credentials to authenticate with the platform. This is a machine-to-machine authentication flow suitable for:
- Backend services
- CLI tools
- Server-side applications
- Batch processing jobs
In production, you would create separate client IDs for each service with appropriate permissions.
TDF Format
The SDKs create TDF (Trusted Data Format) files, which contain:
- Encrypted payload: Your data, encrypted with a symmetric key
- Manifest: Metadata including policy attributes and Key Access Server information
- Policy: Access control rules (which attributes are required to decrypt)
Connection Security
The SDK examples use different settings for local development with self-signed certificates:
Go SDK: sdk.WithInsecureSkipVerifyConn() - Disables TLS certificate verification
Java SDK: SSLFactory.builder().withTrustingAllCertificatesWithoutValidation() - Trusts all certificates
JavaScript SDK: May need NODE_TLS_REJECT_UNAUTHORIZED=0
Never use these settings in production.
In production:
- Use HTTPS connections with valid TLS certificates
- Remove all insecure connection flags
- Configure proper certificate validation
What's Next?
Having issues? See the SDK Troubleshooting guide for solutions to common problems.
Now that you have basic SDK integration working, explore:
- Creating TDFs: Learn about TDF options, attributes, and policies
- Managing Policy: Create and manage attributes programmatically
- Authorization: Check entitlements and authorization decisions
- SDK Feature Matrix: Compare features across SDKs
- Best Practices: Optimize for large-scale operations
Real-World Integration
To integrate OpenTDF into your application:
- Choose Authentication Method: Client credentials, bearer token, or custom auth
- Define Your Attributes: Map your organizational roles and data classifications to attributes
- Create Subject Mappings: Connect users/services to their entitlements
- Encrypt at Rest: Protect files, documents, and data stores
- Encrypt in Transit: Protect data shared between services
- Audit Access: Monitor who accessed what data and when