Skip to content

Commit

Permalink
add DNS name validation, remove TODO
Browse files Browse the repository at this point in the history
Signed-off-by: liudui <[email protected]>
  • Loading branch information
xichengliudui committed Aug 17, 2021
1 parent 2558e7d commit 193ebd5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion proxy-identity/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import (
"path/filepath"
"syscall"

"k8s.io/apimachinery/pkg/util/validation"
"k8s.io/apimachinery/pkg/util/validation/field"

"github.com/linkerd/linkerd2/pkg/tls"
log "github.com/sirupsen/logrus"
)
Expand Down Expand Up @@ -124,11 +127,14 @@ func generateAndStoreKey(p string) (key *ecdsa.PrivateKey, err error) {
}

func generateAndStoreCSR(p, id string, key *ecdsa.PrivateKey) ([]byte, error) {
// TODO do proper DNS name validation.
if id == "" {
return nil, errors.New("a non-empty identity is required")
}

if err := validation.IsFullyQualifiedDomainName(field.NewPath(""), id).ToAggregate(); err != nil {
return nil, fmt.Errorf("%s a fully qualified DNS name is required", id)
}

csr := x509.CertificateRequest{
Subject: pkix.Name{CommonName: id},
DNSNames: []string{id},
Expand Down

0 comments on commit 193ebd5

Please sign in to comment.