Files
tasks/common/rpc/encryption/test_dynamic_cert_provider.go
zeekay 5a601d081b rebrand: go.temporal.io/server -> github.com/hanzoai/tasks
Full module path rebrand from Temporal to Hanzo Tasks:
- go.mod module: github.com/hanzoai/tasks
- All internal Go imports updated (1906 files)
- cmd/server renamed to cmd/tasksd
- Binary name: tasksd (was temporal-server)
- Docker images: hanzoai/tasks (was temporalio/server)
- README rewritten with Hanzo Tasks branding
- LLM.md created with integration notes
- Makefile, goreleaser, CI workflows updated
- go.temporal.io/sdk and go.temporal.io/api imports preserved (separate repos)

Fork of Temporal.io (MIT license).
2026-03-19 10:36:40 -07:00

87 lines
2.1 KiB
Go

package encryption
import (
"crypto/tls"
"crypto/x509"
"time"
"github.com/hanzoai/tasks/common/config"
)
type TestDynamicCertProvider struct {
serverCerts []*tls.Certificate
caCerts *x509.CertPool
wrongCACerts *x509.CertPool
serverCertIndex int
config *config.GroupTLS
serverName string
}
var _ CertProvider = (*TestDynamicCertProvider)(nil)
var _ PerHostCertProviderMap = (*TestDynamicCertProvider)(nil)
func NewTestDynamicCertProvider(
serverCerts []*tls.Certificate,
caCerts *x509.CertPool,
wrongCACerts *x509.CertPool,
config config.GroupTLS) *TestDynamicCertProvider {
return &TestDynamicCertProvider{
serverCerts: serverCerts,
caCerts: caCerts,
wrongCACerts: wrongCACerts,
config: &config,
serverName: "127.0.0.1",
}
}
func (t *TestDynamicCertProvider) FetchServerCertificate() (*tls.Certificate, error) {
i := t.serverCertIndex % len(t.serverCerts)
t.serverCertIndex++
return t.serverCerts[i], nil
}
func (t *TestDynamicCertProvider) FetchClientCAs() (*x509.CertPool, error) {
panic("not implemented")
}
func (t *TestDynamicCertProvider) GetSettings() *config.GroupTLS {
return t.config
}
func (t *TestDynamicCertProvider) FetchClientCertificate(_ bool) (*tls.Certificate, error) {
panic("not implemented")
}
func (t *TestDynamicCertProvider) FetchServerRootCAsForClient(_ bool) (*x509.CertPool, error) {
return t.caCerts, nil
}
func (t *TestDynamicCertProvider) GetCertProvider(hostName string) (CertProvider, bool, error) {
if hostName == "localhost" {
return t, false, nil
}
return nil, false, nil
}
func (t *TestDynamicCertProvider) SwitchToWrongServerRootCACerts() {
t.caCerts = t.wrongCACerts
}
func (t *TestDynamicCertProvider) SetServerName(serverName string) {
t.serverName = serverName
}
func (t *TestDynamicCertProvider) GetExpiringCerts(_ time.Duration,
) (expiring CertExpirationMap, expired CertExpirationMap, err error) {
panic("not implemented")
}
func (t *TestDynamicCertProvider) Initialize(refreshInterval time.Duration) {
panic("implement me")
}
func (t *TestDynamicCertProvider) NumberOfHosts() int {
return 1
}