MCPcopy Create free account
hub / github.com/cloudflare/cfssl / NewSignerFromFile

Function NewSignerFromFile

ocsp/ocsp.go:107–141  ·  view source on GitHub ↗

NewSignerFromFile reads the issuer cert, the responder cert and the responder key from PEM files, and takes an interval in seconds

(issuerFile, responderFile, keyFile string, interval time.Duration)

Source from the content-addressed store, hash-verified

105// NewSignerFromFile reads the issuer cert, the responder cert and the responder key
106// from PEM files, and takes an interval in seconds
107func NewSignerFromFile(issuerFile, responderFile, keyFile string, interval time.Duration) (Signer, error) {
108 log.Debug("Loading issuer cert: ", issuerFile)
109 issuerBytes, err := helpers.ReadBytes(issuerFile)
110 if err != nil {
111 return nil, err
112 }
113 log.Debug("Loading responder cert: ", responderFile)
114 responderBytes, err := os.ReadFile(responderFile)
115 if err != nil {
116 return nil, err
117 }
118 log.Debug("Loading responder key: ", keyFile)
119 keyBytes, err := os.ReadFile(keyFile)
120 if err != nil {
121 return nil, cferr.Wrap(cferr.CertificateError, cferr.ReadFailed, err)
122 }
123
124 issuerCert, err := helpers.ParseCertificatePEM(issuerBytes)
125 if err != nil {
126 return nil, err
127 }
128
129 responderCert, err := helpers.ParseCertificatePEM(responderBytes)
130 if err != nil {
131 return nil, err
132 }
133
134 key, err := helpers.ParsePrivateKeyPEM(keyBytes)
135 if err != nil {
136 log.Debugf("Malformed private key %v", err)
137 return nil, err
138 }
139
140 return NewSigner(issuerCert, responderCert, key, interval)
141}
142
143// NewSigner simply constructs a new StandardSigner object from the inputs,
144// taking the interval in seconds

Callers 7

SignerFromConfigFunction · 0.92
SignerFromConfigFunction · 0.92
NewSignerFromConfigFunction · 0.92
TestNewSignerFromFileFunction · 0.70
TestSignNoResponderFunction · 0.70
TestSignFunction · 0.70
TestSignCustomIntervalFunction · 0.70

Calls 6

DebugFunction · 0.92
ReadBytesFunction · 0.92
ParseCertificatePEMFunction · 0.92
ParsePrivateKeyPEMFunction · 0.92
DebugfFunction · 0.92
NewSignerFunction · 0.70

Tested by 4

TestNewSignerFromFileFunction · 0.56
TestSignNoResponderFunction · 0.56
TestSignFunction · 0.56
TestSignCustomIntervalFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…