Skip to content
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

TrustStore: Generate certificates for tests #3493

Merged
merged 3 commits into from
Dec 9, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions go/lib/infra/modules/trust/v2/testdata/gen_crypto_tar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ do
$1 v2 trcs gen -d $TMP --version $i "1" > /dev/null
done

$1 v2 certs issuer -d $TMP "*-*" > /dev/null
$1 v2 certs chain -d $TMP "*-*" > /dev/null

tar -C $TMP -cf $2 .
1 change: 1 addition & 0 deletions go/tools/scion-pki/internal/v2/certs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ go_library(
"//go/tools/scion-pki/internal/v2/keys:go_default_library",
"//go/tools/scion-pki/internal/v2/trcs:go_default_library",
"@com_github_spf13_cobra//:go_default_library",
"@org_golang_x_xerrors//:go_default_library",
],
)

Expand Down
12 changes: 10 additions & 2 deletions go/tools/scion-pki/internal/v2/certs/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ import (
"regexp"
"strconv"

"golang.org/x/xerrors"

"github.com/scionproto/scion/go/lib/addr"
"github.com/scionproto/scion/go/lib/scrypto"
"github.com/scionproto/scion/go/lib/serrors"
"github.com/scionproto/scion/go/tools/scion-pki/internal/pkicmn"
"github.com/scionproto/scion/go/tools/scion-pki/internal/v2/conf"
)

var errNoFilesFound = serrors.New("no config files found")

type loader struct {
Dirs pkicmn.Dirs
Version scrypto.Version
Expand All @@ -41,7 +45,11 @@ func (l loader) LoadIssuerConfigs(asMap pkicmn.ASMap) (map[addr.IA]conf.Issuer,
for _, ias := range asMap {
for _, ia := range ias {
file, err := l.selectConfig(ia, s)
if err != nil {
switch {
case xerrors.Is(err, errNoFilesFound):
pkicmn.QuietPrint("Ignoring AS without issuer certificate config: %s\n", ia)
continue
case err != nil:
return nil, serrors.WrapStr("unable to select config", err, "ia", ia)
}
cfg, err := conf.LoadIssuer(file)
Expand Down Expand Up @@ -86,7 +94,7 @@ func (l loader) selectConfig(ia addr.IA, s selector) (string, error) {
return "", serrors.WrapStr("unable to search all available versions", err)
}
if len(files) == 0 {
return "", serrors.WrapStr("no config files found", err)
return "", errNoFilesFound
}
max, err := findMaxVersion(files, s.Regex)
if err != nil {
Expand Down