Overview
The copr-keygen component is a Flask-based microservice that generates and manages GPG keys for signing packages. It provides:- On-demand GPG key pair generation
- Secure key and passphrase storage
- Integration with obs-signd for package signing
- Key prolongation and maintenance
Key Technologies
Key Technologies
- Framework: Flask (Python 3)
- Web Server: Apache httpd with mod_wsgi
- GPG: GnuPG 2.x for key operations
- Signing: obs-signd (Open Build Service sign daemon)
- Entropy: haveged for key generation
Architecture
Directory Structure
API Endpoints
REST API
REST API
Health Check
Generate Key
Parameters
name_real(required): Key owner name (project)name_email(required): Key identifier (must be unique)name_comment(optional): Additional descriptionkey_length(optional): 2048 or 4096 bits (default: 2048)expire(optional): Expiration in days (0 = never, default: 0)
Key Generation Process
File Storage
Storage Layout
Storage Layout
Configuration
/etc/copr-keygen/local_settings.py
/etc/copr-keygen/local_settings.py
obs-signd Integration
Package Signing Configuration
Package Signing Configuration
Key Maintenance
Key Prolongation
Key Prolongation
Apache/WSGI Configuration
Security Considerations
Security Best Practices
Security Best Practices
File Permissions
Process Isolation
- Runs as dedicated
copr-signeruser - No shell access for copr-signer user
- Sudo access strictly limited to signing operations
- SELinux policies restrict file access
Passphrase Generation
Network Restrictions
- Listen only on internal network
- Backend authenticates with token/password
- No public access to keygen service
Troubleshooting
Common Issues
Common Issues
Key Generation Hangs
Problem:gpg --gen-key blocks waiting for entropyPermission Denied Errors
Problem: Cannot write to gnupg directoryTrust Database Corruption
Problem: gpg reports trust database errorsobs-signd Not Signing
Problem: Signing fails with authentication errorLogging
Log Files
Log Files
- Application log:
/var/log/copr-keygen/main.log - Apache error log:
/var/log/httpd/copr-keygen-error.log - Apache access log:
/var/log/httpd/copr-keygen-access.log - Sign daemon log:
/var/log/signd.log
Log Format
Dependencies
Core Packages
python3-flask- Web frameworkpython3-copr-common- Shared utilitiesgnupg2- GPG key operationsobs-signd- Package signingpython3-mod_wsgi- WSGI interfacehttpd- Apache web serverhaveged- Entropy generation