Skip to content

Added TLS error check to avoid API Key leakage #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tdx-cli/cmd/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ func getToken(cmd *cobra.Command) error {
return errors.New("Either Trust Authority API URL or Trust Authority API Key is missing in config")
}

if !strings.HasPrefix(config.TrustAuthorityApiUrl, "https://") {
return errors.New("Invalid Trust Authority API URL, must start with 'https://'")
}

_, err = url.ParseRequestURI(config.TrustAuthorityApiUrl)
if err != nil {
return errors.Wrap(err, "Invalid Trust Authority API URL")
Expand Down
5 changes: 5 additions & 0 deletions tdx-cli/cmd/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"fmt"
"net/url"
"os"
"strings"

"github.com/intel/trustauthority-client/go-connector"
"github.com/intel/trustauthority-client/tdx-cli/constants"
Expand Down Expand Up @@ -65,6 +66,10 @@ func verifyToken(cmd *cobra.Command) error {
return errors.New("Trust Authority URL is missing in config")
}

if !strings.HasPrefix(config.TrustAuthorityUrl, "https://") {
return errors.New("Invalid Trust Authority URL, must start with 'https://'")
}

_, err = url.ParseRequestURI(config.TrustAuthorityUrl)
if err != nil {
return errors.Wrap(err, "Invalid Trust Authority URL")
Expand Down