
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
github.com/CrisisTextLine/modular/modules/letsencrypt
The Let's Encrypt module provides automatic SSL/TLS certificate generation and management using Let's Encrypt's ACME protocol. It integrates seamlessly with the Modular framework to provide HTTPS capabilities for your applications.
go get github.com/CrisisTextLine/modular/modules/letsencrypt
package main
import (
"context"
"log/slog"
"os"
"github.com/CrisisTextLine/modular"
"github.com/CrisisTextLine/modular/modules/letsencrypt"
"github.com/CrisisTextLine/modular/modules/httpserver"
)
type AppConfig struct {
LetsEncrypt letsencrypt.LetsEncryptConfig `yaml:"letsencrypt"`
HTTPServer httpserver.HTTPServerConfig `yaml:"httpserver"`
}
func main() {
logger := slog.New(slog.NewTextHandler(os.Stdout, nil))
config := &AppConfig{
LetsEncrypt: letsencrypt.LetsEncryptConfig{
Email: "your-email@example.com",
Domains: []string{"example.com", "www.example.com"},
UseStaging: false, // Set to true for testing
StoragePath: "./certs",
AutoRenew: true,
RenewBefore: 30, // Renew 30 days before expiration
},
HTTPServer: httpserver.HTTPServerConfig{
Host: "0.0.0.0",
Port: 443,
TLS: &httpserver.TLSConfig{Enabled: true},
},
}
configProvider := modular.NewStdConfigProvider(config)
app := modular.NewStdApplication(configProvider, logger)
// Register modules
app.RegisterModule(letsencrypt.NewLetsEncryptModule())
app.RegisterModule(httpserver.NewHTTPServerModule())
if err := app.Run(); err != nil {
logger.Error("Application error", "error", err)
os.Exit(1)
}
}
config := &AppConfig{
LetsEncrypt: letsencrypt.LetsEncryptConfig{
Email: "your-email@example.com",
Domains: []string{"*.example.com", "example.com"},
UseStaging: false,
StoragePath: "./certs",
AutoRenew: true,
UseDNS: true,
DNSProvider: &letsencrypt.DNSProviderConfig{
Name: "cloudflare",
},
DNSConfig: map[string]string{
"CLOUDFLARE_EMAIL": "your-email@example.com",
"CLOUDFLARE_API_KEY": "your-api-key",
},
},
}
Field | Type | Description | Default |
---|---|---|---|
email | string | Email address for Let's Encrypt registration | Required |
domains | []string | List of domain names to obtain certificates for | Required |
use_staging | bool | Use Let's Encrypt staging environment | false |
storage_path | string | Directory for certificate storage | "./letsencrypt" |
renew_before | int | Days before expiry to renew certificates | 30 |
auto_renew | bool | Enable automatic renewal | true |
use_dns | bool | Use DNS-01 challenges instead of HTTP-01 | false |
For DNS challenges, configure the DNS provider:
letsencrypt:
email: "your-email@example.com"
domains:
- "example.com"
- "*.example.com"
use_dns: true
dns_provider:
name: "cloudflare"
dns_config:
CLOUDFLARE_EMAIL: "your-email@example.com"
CLOUDFLARE_API_KEY: "your-api-key"
cloudflare
route53
azuredns
gcloud
digitalocean
namecheap
Each provider requires specific environment variables or configuration parameters.
The Let's Encrypt module works seamlessly with the HTTP Server module by implementing the CertificateService
interface:
// The HTTP server module will automatically use certificates from Let's Encrypt
app.RegisterModule(letsencrypt.NewLetsEncryptModule())
app.RegisterModule(httpserver.NewHTTPServerModule())
// Get certificate service for custom handling
var certService httpserver.CertificateService
app.GetService("certificateService", &certService)
// Get certificate for a specific domain
cert := certService.GetCertificate("example.com")
letsEncryptModule := letsencrypt.NewLetsEncryptModule()
// Force certificate renewal
if err := letsEncryptModule.RenewCertificate("example.com"); err != nil {
log.Printf("Failed to renew certificate: %v", err)
}
You can configure the module using environment variables:
LETSENCRYPT_EMAIL=your-email@example.com
LETSENCRYPT_DOMAINS=example.com,www.example.com
LETSENCRYPT_USE_STAGING=false
LETSENCRYPT_STORAGE_PATH=./certs
LETSENCRYPT_AUTO_RENEW=true
use_staging: true
to avoid rate limitsEnable debug logging to troubleshoot issues:
logger := slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{
Level: slog.LevelDebug,
}))
See the examples directory for complete working examples:
This module is part of the Modular framework and is licensed under the MIT License.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.