feat: S/MIME certificate support in integration tests + test env docs

Add S/MIME (emailProtection EKU) end-to-end test coverage:
- ValidateCommonName() now accepts email addresses for S/MIME certs
- S/MIME test profile (prof-test-smime) in seed data
- Phase 11 test: issuance, EKU, KeyUsage, email SAN verification
- EST config enabled in test Docker Compose
- Portable KeyUsage parsing (awk, works on BSD/GNU)
- Full test environment documentation (docs/test-env.md)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Shankar
2026-04-02 18:32:57 -04:00
parent d0f5fd2dcd
commit c145cedfd0
5 changed files with 1273 additions and 6 deletions
+9
View File
@@ -3,6 +3,7 @@ package handler
import (
"fmt"
"net"
"net/mail"
"strings"
)
@@ -13,6 +14,7 @@ type ValidationError struct {
}
// ValidateCommonName validates a certificate common name.
// Accepts hostnames (TLS), IP addresses, and email addresses (S/MIME).
func ValidateCommonName(cn string) error {
if cn == "" {
return ValidationError{Field: "common_name", Message: "common_name is required"}
@@ -20,6 +22,13 @@ func ValidateCommonName(cn string) error {
if len(cn) > 253 {
return ValidationError{Field: "common_name", Message: "common_name must be 253 characters or fewer"}
}
// If CN contains @, validate as email address (S/MIME certificates)
if strings.Contains(cn, "@") {
if _, err := mail.ParseAddress(cn); err != nil {
return ValidationError{Field: "common_name", Message: fmt.Sprintf("invalid email format for S/MIME common name: %v", err)}
}
return nil
}
// Basic hostname validation: allow alphanumeric, dots, hyphens
if err := isValidHostname(cn); err != nil {
return ValidationError{Field: "common_name", Message: fmt.Sprintf("invalid hostname format: %v", err)}