certificate.go 450 B

123456789101112131415161718192021222324
  1. package adapter
  2. import (
  3. "context"
  4. "crypto/x509"
  5. "github.com/sagernet/sing/service"
  6. )
  7. type CertificateStore interface {
  8. LifecycleService
  9. Pool() *x509.CertPool
  10. TLSDecryptionEnabled() bool
  11. TLSDecryptionCertificate() *x509.Certificate
  12. TLSDecryptionPrivateKey() any
  13. }
  14. func RootPoolFromContext(ctx context.Context) *x509.CertPool {
  15. store := service.FromContext[CertificateStore](ctx)
  16. if store == nil {
  17. return nil
  18. }
  19. return store.Pool()
  20. }