Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate a certificate inside the enclave #2162

Merged
merged 3 commits into from
Dec 2, 2024

Conversation

zkokelj
Copy link
Contributor

@zkokelj zkokelj commented Nov 26, 2024

Why this change is needed

We want to guarantee e2e encryption between the user and the gateway. To have this we need to terminate our https connection inside the enclave and this means also generating a certificate within the enclave.

What changes were made as part of this PR

  • https server instead of http server
  • 2 new parameters for the gateway: enableTLS, tlsDomain
  • updated deployment script
  • generating and auto renewal of certificates inside the enclave

Description of what is happening behind the scenes in library

We use autocert library and call GetCertificate to obtain the certificate.
If check if the cert already exists and proceeds to obtain it only in case it doesn't.

Generating a certificate consists of the following steps:

  • generating a new private key
  • domain ownership verification (HTTP-01 challenge since certManager.HTTPHandler(nil) is set)
  • Certificate Signing Request (CRS) is generated
  • CRS is sent to CA (Let's Encrypt) via ACME (automated certificate management environment) client
  • CA verifies CRS and issues a certificate
  • we store store certificate and private key (in memory and also in on a mounted volume attached to docker container)

Certificate and private key are stored on a mounted volume (same as sealed key for database key encryption) and this private key is then used also for renewing the certificate and in case of restarts/upgrades of the gateway.

image

PR checks pre-merging

Please indicate below by ticking the checkbox that you have read and performed the required
PR checks

  • PR checks reviewed and performed

@zkokelj zkokelj force-pushed the ziga/gateway_terminate_https_inside_enclave branch from ac595ab to 62dfc0e Compare December 2, 2024 12:42
Copy link
Collaborator

@tudor-malene tudor-malene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Let's store the cert in the DB in the next PR

// check if TLS is enabled
if config.EnableTLS {
// Create autocert manager for automatic certificate management
certManager := &autocert.Manager{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls add the details about what happens in the library from the description here as a comment

@zkokelj zkokelj merged commit 52c5c17 into main Dec 2, 2024
2 checks passed
@zkokelj zkokelj deleted the ziga/gateway_terminate_https_inside_enclave branch December 2, 2024 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants