internal/cryptutil: fixed panic on nil pubkey

This commit is contained in:
Bobby DeSimone 2019-07-15 19:36:02 -07:00
parent 22fb3a0f7e
commit c5bcc9bbef
No known key found for this signature in database
GPG key ID: AEE4CF12FE86D07E
5 changed files with 81 additions and 13 deletions

View file

@ -1,4 +1,4 @@
package cryptutil
package cryptutil // import "github.com/pomerium/pomerium/internal/cryptutil"
import (
"bytes"
@ -35,6 +35,10 @@ func TestPublicKeyMarshaling(t *testing.T) {
if err != nil {
t.Fatal(err)
}
_, err = DecodePublicKey(nil)
if err == nil {
t.Fatal("expected error")
}
pemBytes, _ := EncodePublicKey(ecKey)
if !bytes.Equal(pemBytes, []byte(pemECPublicKeyP256)) {