MCPcopy Index your code
hub / github.com/cortexproject/cortex / writeExclusivePEMFile

Function writeExclusivePEMFile

integration/ca/ca.go:49–60  ·  view source on GitHub ↗
(path, marker string, mode os.FileMode, data []byte)

Source from the content-addressed store, hash-verified

47}
48
49func writeExclusivePEMFile(path, marker string, mode os.FileMode, data []byte) (err error) {
50 f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_EXCL, mode)
51 if err != nil {
52 return err
53 }
54 defer runutil.CloseWithErrCapture(&err, f, "write pem file")
55
56 if err := pem.Encode(f, &pem.Block{Type: marker, Bytes: data}); err != nil {
57 return err
58 }
59 return nil
60}
61
62func (ca *CA) WriteCACertificate(path string) error {
63 derBytes, err := x509.CreateCertificate(rand.Reader, ca.cert, ca.cert, ca.key.Public(), ca.key)

Callers 2

WriteCACertificateMethod · 0.85
WriteCertificateMethod · 0.85

Calls 2

CloseWithErrCaptureFunction · 0.92
EncodeMethod · 0.65

Tested by

no test coverage detected