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

amppkg_dl_sxg: add -cert_url_path to override cert-url #329

Merged
merged 1 commit into from
Jul 15, 2019

Conversation

shigeki
Copy link
Contributor

@shigeki shigeki commented Jul 12, 2019

During renewing of SXG cert in cluster servers, the new cert cannot
be obtained in requesting cert-url from the cluster. -cert_url_path
option enables us to overriding scheme, hostname and path of cert-url
so that we can obtain the newer cert by specifying a server.

In the server, we can get a new cert and confirm its cert renewal by
using localhost such as

amppkg_dl_sxg -cert_url_path http://localhost:8080/amppkg/cert/ http://localhost:8080/priv/doc?...

Copy link
Member

@twifkak twifkak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Minor, optional comments.

@@ -17,6 +19,7 @@ import (

var flagOutSXG = flag.String("out_sxg", "test.sxg", "Path to where the signed-exchange should be saved.")
var flagOutCert = flag.String("out_cert", "test.cert", "Path to where the cert-chain+cbor should be saved.")
var flagCertURL = flag.String("cert_url_path", "", "Override scheme, hostname and path in cert-url.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to cert_url_base. (Maybe s/path/parent path/ in the flag description?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

if err != nil {
log.Fatalf("%+v", err)
}
fURL, err := url.Parse(*flagCertURL)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move this url.Parse call inside the if *flagCertURL?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

log.Fatalf("%+v", err)
}
if *flagCertURL != "" {
cURL.Scheme = fURL.Scheme
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about something like:

certHash := path.Base(cURL.Path)
cURL = fURL
cURL.Path = path.Join(cURL.Path, certHash)

That way, the user can provide a user:pass@ or ?query too. (Admittedly, rare cases.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

During renewing of SXG cert in cluster servers, the new cert cannot
be obtained in requesting cert-url from the cluster. `-cert_url_base`
option enables us to overriding scheme, hostname and parent path of
cert-url so that we can obtain the newer cert by specifying a server.

In the server, we can get a new cert and confirm its cert renewal by
using localhost such as

`amppkg_dl_sxg -cert_url_base http://localhost:8080/amppkg/cert/ http://localhost:8080/priv/doc?...`
@shigeki
Copy link
Contributor Author

shigeki commented Jul 15, 2019

Thanks for your review. Fixes were done according to your comments.

@twifkak
Copy link
Member

twifkak commented Jul 15, 2019

Thanks, merging.

@twifkak twifkak merged commit 674615b into ampproject:master Jul 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants