certificate.go 344 B

123456789101112131415161718192021
  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. }
  11. func RootPoolFromContext(ctx context.Context) *x509.CertPool {
  12. store := service.FromContext[CertificateStore](ctx)
  13. if store == nil {
  14. return nil
  15. }
  16. return store.Pool()
  17. }