Skip to content

Commit e416691

Browse files
authored
Integrate CertFetcher with flag-protection into AMP Packager. (#349)
* Update ACME config to include email adddress and acme challenge port. Update certcache to use certfetcher if cert autorenew is turned on. Update certloader.PopulateCertCache to instantiate certfetcher and pass it on to certcache instance. * Add config file error checking for PopulateCertCache. * Add more logic to handle initial conditions with invalid cert and to address comments from gregable@. * Code refactor/cleanup involving certs. * Add DNS and TLS challenges, added them to load from config, cleaned up autorenewcert config parsing. * go mod tidy, go mod vendor updates * Fixed CSR Loading, added it to config * Fixed bugs with checking for cert expiry. * Added support for saving the fetched certs to disk and for certs to be loaded by non-auto-renewing amppackager instances. * Fixed gateway server call to certcache. Removed go module files inside gateway server dir. Re-ran go mod tidy. * Fixed certcache_test.go after merge. * Fixed bugs in certcache, also fixed unit test. * Added locking for reading/writing certs. * Ran go fmt on files that have incorrect formatting * Fix twifkak first-pass comments except the logic change comment which I will address in a later commit. * Fix twifkak comments for ocsp refresh logic and ocsp cache purge. * Fix additional twifkak comments. * Fix 2nd round of twifkak comments. * Fix gregable@ comments.
1 parent 76826b5 commit e416691

File tree

2,037 files changed

+356444
-178
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,037 files changed

+356444
-178
lines changed

cmd/amppkg/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828

2929
"github.com/pkg/errors"
3030

31+
"github.com/ampproject/amppackager/packager/certcache"
3132
"github.com/ampproject/amppackager/packager/certloader"
3233
"github.com/ampproject/amppackager/packager/healthz"
3334
"github.com/ampproject/amppackager/packager/mux"
@@ -41,6 +42,9 @@ var flagConfig = flag.String("config", "amppkg.toml", "Path to the config toml f
4142
var flagDevelopment = flag.Bool("development", false, "True if this is a development server.")
4243
var flagInvalidCert = flag.Bool("invalidcert", false, "True if invalid certificate intentionally used in production.")
4344

45+
// IMPORTANT: do not turn on this flag for now, it's still under development.
46+
var flagAutoRenewCert = flag.Bool("autorenewcert", false, "True if amppackager is to attempt cert auto-renewal.")
47+
4448
// Prints errors returned by pkg/errors with stack traces.
4549
func die(err interface{}) { log.Fatalf("%+v", err) }
4650

@@ -83,7 +87,7 @@ func main() {
8387
die(errors.Wrap(err, "loading key file"))
8488
}
8589

86-
certCache, err := certloader.PopulateCertCache(config, key, *flagDevelopment || *flagInvalidCert);
90+
certCache, err := certcache.PopulateCertCache(config, key, *flagDevelopment || *flagInvalidCert, *flagAutoRenewCert)
8791
if err != nil {
8892
die(errors.Wrap(err, "building cert cache"))
8993
}

cmd/gateway_server/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func (s *gatewayServer) GenerateSXG(ctx context.Context, request *pb.SXGRequest)
7474
}
7575

7676
// Note: do not initialize certCache, we just want it to hold the certs for now.
77-
certCache := certcache.New(certs, "");
77+
certCache := certcache.New(certs, nil, []string{""}, "", "", "");
7878

7979
privateKey, err := util.ParsePrivateKey(request.PrivateKey)
8080
if err != nil {

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ require (
1515
github.com/stretchr/testify v1.3.0
1616
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4
1717
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c
18+
google.golang.org/grpc v1.20.1
1819
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
1920
gopkg.in/square/go-jose.v2 v2.3.1
2021
)

go.sum

Lines changed: 79 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)