Skip to content

Commit 69f1d69

Browse files
committed
fix issuer path
1 parent c1e016f commit 69f1d69

7 files changed

Lines changed: 24 additions & 15 deletions

File tree

cmd/aws/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ func newAWSStorage(ctx context.Context, signer note.Signer) (*storage.CTStorage,
190190
return nil, fmt.Errorf("failed to initialize AWS Tessera storage: %v", err)
191191
}
192192

193-
issuerStorage, err := aws.NewIssuerStorage(ctx, *bucket, "fingerprints/", "application/pkix-cert")
193+
issuerStorage, err := aws.NewIssuerStorage(ctx, *bucket)
194194
if err != nil {
195195
return nil, fmt.Errorf("failed to initialize AWS issuer storage: %v", err)
196196
}

cmd/gcp/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ func newGCPStorage(ctx context.Context, signer note.Signer) (*storage.CTStorage,
203203
return nil, fmt.Errorf("failed to initialize GCP Tessera appender: %v", err)
204204
}
205205

206-
issuerStorage, err := gcp.NewIssuerStorage(ctx, *bucket, "fingerprints/", "application/pkix-cert")
206+
issuerStorage, err := gcp.NewIssuerStorage(ctx, *bucket)
207207
if err != nil {
208208
return nil, fmt.Errorf("failed to initialize GCP issuer storage: %v", err)
209209
}

internal/ct/handlers_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ var (
7272
TimeSource: timeSource,
7373
}
7474

75-
// POSIX subdirectories
75+
// POSIX subdirectory
7676
logDir = "log"
77-
issDir = "issuers"
7877
)
7978

8079
type fixedTimeSource struct {
@@ -180,7 +179,7 @@ func newPOSIXStorageFunc(t *testing.T, root string) storage.CreateStorage {
180179
klog.Fatalf("Failed to initialize POSIX Tessera appender: %v", err)
181180
}
182181

183-
issuerStorage, err := posix.NewIssuerStorage(path.Join(root, issDir))
182+
issuerStorage, err := posix.NewIssuerStorage(path.Join(root, logDir))
184183
if err != nil {
185184
klog.Fatalf("failed to initialize InMemory issuer storage: %v", err)
186185
}
@@ -589,7 +588,7 @@ func TestAddChain(t *testing.T) {
589588
// Check that the issuers have been populated correctly.
590589
for _, wantIss := range wantIssChain[1:] {
591590
key := sha256.Sum256(wantIss.Raw)
592-
issPath := path.Join(dir, issDir, hex.EncodeToString(key[:]))
591+
issPath := path.Join(dir, logDir, staticct.IssuersPrefix, hex.EncodeToString(key[:]))
593592
gotIss, err := os.ReadFile(issPath)
594593
if err != nil {
595594
t.Errorf("Failed to read issuer at %q: %v", issPath, err)
@@ -736,7 +735,7 @@ func TestAddPreChain(t *testing.T) {
736735
// Check that the issuers have been populated correctly.
737736
for _, wantIss := range wantIssChain[1:] {
738737
key := sha256.Sum256(wantIss.Raw)
739-
issPath := path.Join(dir, issDir, hex.EncodeToString(key[:]))
738+
issPath := path.Join(dir, logDir, staticct.IssuersPrefix, hex.EncodeToString(key[:]))
740739
gotIss, err := os.ReadFile(issPath)
741740
if err != nil {
742741
t.Errorf("Failed to read issuer at %q: %v", issPath, err)

internal/testonly/storage/posix/issuers.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ import (
2323
"fmt"
2424
"os"
2525
"path"
26+
"path/filepath"
2627
"strings"
2728

29+
"github.com/transparency-dev/tesseract/internal/types/staticct"
2830
"github.com/transparency-dev/tesseract/storage"
2931
"k8s.io/klog/v2"
3032
)
@@ -37,10 +39,11 @@ type IssuersStorage string
3739
// It creates the underying directory if it does not exist already.
3840
func NewIssuerStorage(path string) (IssuersStorage, error) {
3941
// Does nothing if the dictory already exists.
40-
if err := os.MkdirAll(path, 0755); err != nil {
42+
p := filepath.Join(path, staticct.IssuersPrefix)
43+
if err := os.MkdirAll(p, 0755); err != nil {
4144
return "", fmt.Errorf("failed to create path %q: %v", path, err)
4245
}
43-
return IssuersStorage(path), nil
46+
return IssuersStorage(p), nil
4447
}
4548

4649
// keyToObjName converts bytes to filesystem path.

internal/types/staticct/staticct.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ import (
2424
"golang.org/x/crypto/cryptobyte"
2525
)
2626

27+
const (
28+
IssuersPrefix = "issuer/"
29+
IssuersContentType = "application/pkix-cert"
30+
)
31+
2732
///////////////////////////////////////////////////////////////////////////////
2833
// The following structures represent those outlined in Static CT API.
2934
///////////////////////////////////////////////////////////////////////////////

storage/aws/issuers.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/aws/aws-sdk-go-v2/config"
2626
"github.com/aws/aws-sdk-go-v2/service/s3"
2727
"github.com/aws/smithy-go"
28+
"github.com/transparency-dev/tesseract/internal/types/staticct"
2829
"github.com/transparency-dev/tesseract/storage"
2930
"k8s.io/klog/v2"
3031
)
@@ -40,7 +41,7 @@ type IssuersStorage struct {
4041
// NewIssuerStorage creates a new IssuerStorage.
4142
//
4243
// The specified bucket must exist or an error will be returned.
43-
func NewIssuerStorage(ctx context.Context, bucket string, prefix string, contentType string) (*IssuersStorage, error) {
44+
func NewIssuerStorage(ctx context.Context, bucket string) (*IssuersStorage, error) {
4445
sdkConfig, err := config.LoadDefaultConfig(ctx)
4546
if err != nil {
4647
return nil, fmt.Errorf("failed to load default AWS configuration: %v", err)
@@ -49,8 +50,8 @@ func NewIssuerStorage(ctx context.Context, bucket string, prefix string, content
4950
r := &IssuersStorage{
5051
s3Client: s3.NewFromConfig(sdkConfig),
5152
bucket: bucket,
52-
prefix: prefix,
53-
contentType: contentType,
53+
prefix: staticct.IssuersPrefix,
54+
contentType: staticct.IssuersContentType,
5455
}
5556

5657
return r, nil

storage/gcp/issuers.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"path"
2222

2323
gcs "cloud.google.com/go/storage"
24+
"github.com/transparency-dev/tesseract/internal/types/staticct"
2425
"github.com/transparency-dev/tesseract/storage"
2526
"google.golang.org/api/googleapi"
2627
"k8s.io/klog/v2"
@@ -36,16 +37,16 @@ type IssuersStorage struct {
3637
// NewIssuerStorage creates a new GCSStorage.
3738
//
3839
// The specified bucket must exist or an error will be returned.
39-
func NewIssuerStorage(ctx context.Context, bucket string, prefix string, contentType string) (*IssuersStorage, error) {
40+
func NewIssuerStorage(ctx context.Context, bucket string) (*IssuersStorage, error) {
4041
c, err := gcs.NewClient(ctx, gcs.WithJSONReads())
4142
if err != nil {
4243
return nil, fmt.Errorf("failed to create GCS client: %v", err)
4344
}
4445

4546
r := &IssuersStorage{
4647
bucket: c.Bucket(bucket),
47-
prefix: prefix,
48-
contentType: contentType,
48+
prefix: staticct.IssuersPrefix,
49+
contentType: staticct.IssuersContentType,
4950
}
5051

5152
return r, nil

0 commit comments

Comments
 (0)