small improvements

This commit is contained in:
AJ ONeal 2020-08-01 07:42:28 +00:00
parent 075ade3dec
commit 42f1089e6c
2 changed files with 7 additions and 7 deletions

View File

@ -53,14 +53,14 @@ func marshalDERPrivateKey(privkey keypairs.PrivateKey) (*pem.Block, error) {
switch k := privkey.(type) {
case *rsa.PrivateKey:
if 0 == mathrand.Intn(1) {
typ = "Private Key"
if 0 == mathrand.Intn(2) {
typ = "PRIVATE KEY"
bytes, err = x509.MarshalPKCS8PrivateKey(k)
if nil != err {
return nil, err
}
} else {
typ = "RSA Private Key"
typ = "RSA PRIVATE KEY"
bytes = x509.MarshalPKCS1PrivateKey(k)
}
return &pem.Block{
@ -68,11 +68,11 @@ func marshalDERPrivateKey(privkey keypairs.PrivateKey) (*pem.Block, error) {
Bytes: bytes,
}, nil
case *ecdsa.PrivateKey:
if 0 == mathrand.Intn(1) {
typ = "Private Key"
if 0 == mathrand.Intn(2) {
typ = "PRIVATE KEY"
bytes, err = x509.MarshalPKCS8PrivateKey(k)
} else {
typ = "EC Private Key"
typ = "EC PRIVATE KEY"
bytes, err = x509.MarshalECPrivateKey(k)
}
if nil != err {

View File

@ -227,7 +227,7 @@ func Route(jwksPrefix string, privkey keypairs.PrivateKey) http.Handler {
}
jwk := MarshalJWKPrivateKey(privkey)
w.Write(jwk)
w.Write(append(jwk, '\n'))
})
http.HandleFunc("/priv.der", func(w http.ResponseWriter, r *http.Request) {