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

@ -6,6 +6,7 @@ import (
"encoding/pem" "encoding/pem"
"errors" "errors"
"fmt" "fmt"
"io"
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
@ -126,3 +127,26 @@ func (ca *CA) load() error {
func (ca *CA) create() error { func (ca *CA) create() error {
return nil 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 package proxy
import ( import (
"fmt" "os"
"testing" "testing"
) )
@ -20,5 +20,9 @@ func TestNewCA(t *testing.T) {
if err != nil { if err != nil {
t.Error(err) t.Error(err)
} }
fmt.Println(ca)
err = ca.saveTo(os.Stdout)
if err != nil {
t.Error(err)
}
} }

Loading…
Cancel
Save