Understanding Module Signing
Why Sign Your Module?
Module signing serves several critical purposes:
- Authenticity: Verifies you're the creator
- Integrity: Ensures the module hasn't been tampered with
- Trust: Helps users verify the module source
- Gateway Security: Required for module acceptance
Certificate Types
Self-Signed (../Development)
- Quick to create
- Good for testing
- Not recommended for production
- No third-party verification
CA-Signed (Production)
- Verified by trusted authority
- More secure
- Required for public distribution
- Takes longer to obtain
Creating Certificates
Development Certificate
# Generate a keystore and certificate
keytool -genkeypair \
-alias mymodule \
-keyalg RSA \
-keysize 2048 \
-keystore keystore.jks \
-validity 3650
This command:
- Creates a new keystore (
keystore.jks) - Generates an RSA key pair
- Sets a 10-year validity period
- Stores under alias 'mymodule'
Key Size
We use 2048-bit RSA keys as a good balance between security and performance. 4096-bit keys are also acceptable but may impact build times.
Production Certificate Process
-
Generate CSR:
keytool -certreq \
-alias mymodule \
-file module.csr \
-keystore keystore.jks -
Submit to CA:
- Choose a reputable Certificate Authority
- Follow their verification process
- Pay any required fees
-
Import Signed Certificate:
keytool -importcert \
-alias mymodule \
-file signed_cert.crt \
-keystore keystore.jks
How Signing Works
- Build Process: Creates module content
- Hashing: Creates unique fingerprint
- Signing: Encrypts hash with private key
- Verification: Gateway checks signature
Implementing Signing
Local Development
In gradle.properties:
signModule=true
Build command:
./gradlew build signModule \
--certFile=module.crt \
--certPassword=password \
--keystoreFile=keystore.jks \
--keystorePassword=password \
--certAlias=mymodule
CI/CD Integration
Store certificates securely:
- Base64 encode files
- Add to CI/CD secrets
- Decode during build
# Encode for CI/CD
base64 -w 0 cert.crt > cert.base64
base64 -w 0 keystore.jks > keystore.base64
Verifying Signatures
Check Module Signature
keytool -printcert -file MyModule.modl
Gateway Verification
- Gateway receives module
- Extracts certificate
- Validates signature
- Checks certificate trust
Best Practices
-
Key Security
- Secure private key storage
- Limited access to certificates
- Regular key rotation
-
Certificate Management
- Track expiration dates
- Plan renewal process
- Backup certificates safely
-
Development Flow
- Use self-signed for testing
- CA-signed for production
- Document certificate details
Certificate Storage
Never commit certificates or keystores to version control. Store securely and distribute through protected channels.
Common Issues
Certificate Errors
- Problem: Gateway rejects signature
- Solution: Verify certificate chain and trust
Signing Failures
- Problem: Build signing fails
- Solution: Check certificate and password accuracy