MCPcopy Create free account
hub / github.com/containerd/nerdctl / writePair

Function writePair

pkg/testutil/testca/testca.go:139–153  ·  view source on GitHub ↗
(t testing.TB, keyPath, certPath string, cert, caCert *x509.Certificate, key, caKey *rsa.PrivateKey)

Source from the content-addressed store, hash-verified

137}
138
139func writePair(t testing.TB, keyPath, certPath string, cert, caCert *x509.Certificate, key, caKey *rsa.PrivateKey) {
140 keyF, err := os.Create(keyPath)
141 assert.NilError(t, err)
142 defer keyF.Close()
143 assert.NilError(t, pem.Encode(keyF, &pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(key)}))
144 assert.NilError(t, keyF.Close())
145
146 certB, err := x509.CreateCertificate(rand.Reader, cert, caCert, &key.PublicKey, caKey)
147 assert.NilError(t, err)
148 certF, err := os.Create(certPath)
149 assert.NilError(t, err)
150 defer certF.Close()
151 assert.NilError(t, pem.Encode(certF, &pem.Block{Type: "CERTIFICATE", Bytes: certB}))
152 assert.NilError(t, certF.Close())
153}
154
155func serialNumber(t testing.TB) *big.Int {
156 serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 60)

Callers 2

NewFunction · 0.85
NewCertMethod · 0.85

Calls 3

EncodeMethod · 0.80
CreateMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…