MCPcopy Create free account
hub / github.com/prometheus/common / writeCertificateAndKey

Function writeCertificateAndKey

config/generate.go:164–185  ·  view source on GitHub ↗
(path string, cert *x509.Certificate, key *rsa.PrivateKey)

Source from the content-addressed store, hash-verified

162}
163
164func writeCertificateAndKey(path string, cert *x509.Certificate, key *rsa.PrivateKey) error {
165 var b bytes.Buffer
166
167 if err := EncodeCertificate(&b, cert); err != nil {
168 return err
169 }
170
171 if err := os.WriteFile(fmt.Sprintf("%s.crt", path), b.Bytes(), 0o644); err != nil {
172 return err
173 }
174
175 b.Reset()
176 if err := EncodeKey(&b, key); err != nil {
177 return err
178 }
179
180 if err := os.WriteFile(fmt.Sprintf("%s.key", path), b.Bytes(), 0o644); err != nil {
181 return err
182 }
183
184 return nil
185}
186
187func main() {
188 log.Println("Generating root CA")

Callers 1

mainFunction · 0.85

Calls 2

EncodeCertificateFunction · 0.85
EncodeKeyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…