This example demonstrates how to configure TLS encryption for secure Flight connections.
For testing purposes, generate self-signed certificates:
# Generate CA
openssl genrsa -out ca-key.pem 4096
openssl req -new -x509 -days 365 -key ca-key.pem -out ca-cert.pem \
-subj "/CN=Test CA"
# Generate server certificate
openssl genrsa -out server-key.pem 4096
openssl req -new -key server-key.pem -out server.csr \
-subj "/CN=localhost"
openssl x509 -req -days 365 -in server.csr -CA ca-cert.pem -CAkey ca-key.pem \
-CAcreateserial -out server-cert.pemcd examples/tls
go run main.goATTACH '' AS secure_data (TYPE airport, LOCATION 'grpc+tls://localhost:50051');
SELECT * FROM secure_data.secure.messages;If the server requires authentication, configure DuckDB with a bearer token:
CREATE SECRET airport_tls (
TYPE AIRPORT,
auth_token 'your-bearer-token',
scope 'grpc+tls://localhost:50051'
);
ATTACH '' AS secure_data (
TYPE airport,
SECRET airport_tls,
LOCATION 'grpc+tls://localhost:50051'
);Note: DuckDB Airport currently supports TLS for transport encryption only. Client certificate authentication (mTLS) is not yet supported in the Airport extension.
tlsConfig := &tls.Config{
Certificates: []tls.Certificate{serverCert},
ClientAuth: tls.RequireAndVerifyClientCert, // Enable mTLS
ClientCAs: certPool,
MinVersion: tls.VersionTLS13, // Use TLS 1.3
}The server-side code supports various TLS client authentication modes:
tls.NoClientCert- Server-only TLS (default, recommended for DuckDB Airport)tls.RequestClientCert- Request but don't verify client certtls.RequireAnyClientCert- Require client cert, any CAtls.VerifyClientCertIfGiven- Verify if providedtls.RequireAndVerifyClientCert- Mutual TLS (mTLS)
Note: While the server supports mTLS, DuckDB Airport extension currently only supports TLS transport without client certificates. Use bearer token authentication if you need client authentication.
-
Certificate Management
- Use proper CA-signed certificates
- Implement certificate rotation
- Store private keys securely (e.g., HSM, secrets manager)
-
TLS Version
- Use TLS 1.3 when possible
- Minimum TLS 1.2 for compatibility
-
Cipher Suites
- Configure strong cipher suites
- Disable weak ciphers
-
Certificate Validation
- Verify certificate chains
- Check certificate revocation (CRL/OCSP)
- Validate hostname/SAN
-
Monitoring
- Log TLS handshake failures
- Monitor certificate expiration
- Alert on weak cipher usage