|
| 1 | +# Common Certificate Management Utilities |
| 2 | + |
| 3 | +This directory contains shared utilities for creating and managing custom TLS certificates using cert-manager in OpenStack operator kuttl tests. |
| 4 | + |
| 5 | +## Files |
| 6 | + |
| 7 | +- **`create_custom_cert.sh`** - Main script with bash functions for certificate creation |
| 8 | +- **`osp_check_route_cert.sh`** - Verification script for route certificates |
| 9 | +- **`verify_route_override_certs.sh`** - Verification script for OpenStackControlPlane overrides |
| 10 | +- **`prepare_placement_certs.sh`** - Helper script to create ConfigMap from certificates |
| 11 | +- **`custom-ingress-issuer.yaml`** - YAML template for custom ingress issuer |
| 12 | +- **`custom-internal-issuer.yaml`** - YAML template for custom internal issuer |
| 13 | +- **`custom-barbican-route.yaml`** - Pre-generated barbican route secret |
| 14 | +- **`custom-ca.yaml`** - Custom CA bundle for testing |
| 15 | + |
| 16 | +## Quick Reference |
| 17 | + |
| 18 | +### Create Certificates for Barbican and Placement |
| 19 | + |
| 20 | +```bash |
| 21 | +source ../../common/create_custom_cert.sh |
| 22 | +INGRESS_DOMAIN=$(oc get ingresses.config.openshift.io cluster -o jsonpath='{.spec.domain}') |
| 23 | +create_barbican_placement_routes "${INGRESS_DOMAIN}" "${NAMESPACE}" |
| 24 | +``` |
| 25 | + |
| 26 | +### Main Functions |
| 27 | + |
| 28 | +| Function | Usage | Description | |
| 29 | +|----------|-------|-------------| |
| 30 | +| `create_barbican_placement_routes` | `<ingress-domain> [namespace]` | One-command setup for barbican and placement | |
| 31 | +| `create_service_route_certificate` | `<service-name> <ingress-domain> [namespace]` | Create certificate for any service | |
| 32 | +| `create_custom_issuer` | `<issuer-name> [namespace]` | Create root CA and issuer | |
| 33 | +| `create_wildcard_certificate` | `<cert-name> <domain> [issuer-name] [namespace]` | Create wildcard certificate | |
| 34 | +| `setup_custom_certificate_infrastructure` | `[namespace]` | Setup complete cert infrastructure | |
| 35 | +| `cleanup_custom_certificates` | `[namespace]` | Remove all custom certificates | |
| 36 | + |
| 37 | +### Verification Functions |
| 38 | + |
| 39 | +```bash |
| 40 | +# Verify route certificate matches secret |
| 41 | +bash ../../common/osp_check_route_cert.sh <service-name> |
| 42 | + |
| 43 | +# Verify OpenStackControlPlane override matches secret |
| 44 | +bash ../../common/verify_route_override_certs.sh <service-name> |
| 45 | +``` |
| 46 | + |
| 47 | +## Certificate Specifications |
| 48 | + |
| 49 | +### Root CA Certificate |
| 50 | +- **Algorithm:** ECDSA P-256 |
| 51 | +- **Duration:** 87600h (10 years) |
| 52 | +- **Usage:** Certificate Sign, CRL Sign |
| 53 | +- **IsCA:** true |
| 54 | + |
| 55 | +### Service Certificates |
| 56 | +- **Algorithm:** ECDSA P-256 |
| 57 | +- **Duration:** 8760h (1 year) |
| 58 | +- **Renewal:** 720h (30 days) before expiration |
| 59 | +- **Usage:** Server Auth, Client Auth |
| 60 | +- **DNS Names:** `*.domain.com`, `domain.com` |
| 61 | + |
| 62 | +## Usage in Kuttl Tests |
| 63 | + |
| 64 | +```yaml |
| 65 | +apiVersion: kuttl.dev/v1beta1 |
| 66 | +kind: TestStep |
| 67 | +commands: |
| 68 | + - script: | |
| 69 | + source ../../common/create_custom_cert.sh |
| 70 | + INGRESS_DOMAIN=$(oc get ingresses.config.openshift.io cluster -o jsonpath='{.spec.domain}') |
| 71 | + create_barbican_placement_routes "${INGRESS_DOMAIN}" "${NAMESPACE}" |
| 72 | +``` |
| 73 | +
|
| 74 | +## Examples |
| 75 | +
|
| 76 | +### Create Certificates for Any Service |
| 77 | +
|
| 78 | +```bash |
| 79 | +source ../../common/create_custom_cert.sh |
| 80 | + |
| 81 | +# For keystone |
| 82 | +create_service_route_certificate "keystone" "apps-crc.testing" "openstack-kuttl-tests" |
| 83 | + |
| 84 | +# For glance |
| 85 | +create_service_route_certificate "glance" "apps-crc.testing" "openstack-kuttl-tests" |
| 86 | +``` |
| 87 | + |
| 88 | +### Setup Complete Infrastructure |
| 89 | + |
| 90 | +```bash |
| 91 | +# Creates both ingress and internal issuers |
| 92 | +setup_custom_certificate_infrastructure "openstack-kuttl-tests" |
| 93 | +``` |
| 94 | + |
| 95 | +### Cleanup |
| 96 | + |
| 97 | +```bash |
| 98 | +# Remove all custom certificates and issuers |
| 99 | +cleanup_custom_certificates "openstack-kuttl-tests" |
| 100 | +``` |
| 101 | + |
| 102 | +## Security Considerations |
| 103 | + |
| 104 | +⚠️ **Important:** These certificates are for **TESTING PURPOSES ONLY** |
| 105 | + |
| 106 | +## Complete Documentation |
| 107 | + |
| 108 | +For detailed documentation including test flow, architecture, troubleshooting, and implementation details, see: |
| 109 | + |
| 110 | +**[tests/kuttl/tests/ctlplane-tls-custom-route/README.md](../tests/ctlplane-tls-custom-route/README.md)** |
| 111 | + |
| 112 | +## Related Documentation |
| 113 | + |
| 114 | +- [Cert-Manager Documentation](https://cert-manager.io/docs/) |
| 115 | +- [ctlplane-tls-custom-route Test](../tests/ctlplane-tls-custom-route/README.md) |
0 commit comments