addon-dailer
lqqyt2423 4 years ago
parent 092166d2e8
commit 5121bb5689

@ -6,6 +6,7 @@ import (
"encoding/pem"
"errors"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
@ -126,3 +127,26 @@ func (ca *CA) load() error {
func (ca *CA) create() error {
return nil
}
func (ca *CA) saveTo(out io.Writer) error {
keyBytes, err := x509.MarshalPKCS8PrivateKey(&ca.PrivateKey)
if err != nil {
return err
}
err = pem.Encode(out, &pem.Block{Type: "PRIVATE KEY", Bytes: keyBytes})
if err != nil {
return err
}
err = pem.Encode(out, &pem.Block{Type: "CERTIFICATE", Bytes: ca.RootCert.Raw})
if err != nil {
return err
}
return nil
}
func (ca *CA) save() error {
return nil
}

@ -1,7 +1,7 @@
package proxy
import (
"fmt"
"os"
"testing"
)
@ -20,5 +20,9 @@ func TestNewCA(t *testing.T) {
if err != nil {
t.Error(err)
}
fmt.Println(ca)
err = ca.saveTo(os.Stdout)
if err != nil {
t.Error(err)
}
}

Loading…
Cancel
Save