Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Unified Diff: web_page_replay_go/src/wpr.go

Issue 2997573003: [wpr-go] Add support install test root CA on Android (Closed)
Patch Set: roll binary Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « web_page_replay_go/src/webpagereplay/installroot.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: web_page_replay_go/src/wpr.go
diff --git a/web_page_replay_go/src/wpr.go b/web_page_replay_go/src/wpr.go
index 159b9dbf8ee5c3586d94026824cf0c42ad3a9416..b139e88a1cfa949b6e678630532552a32a38a3d2 100644
--- a/web_page_replay_go/src/wpr.go
+++ b/web_page_replay_go/src/wpr.go
@@ -83,6 +83,7 @@ type ReplayCommand struct {
type RootCACommand struct {
certConfig CertConfig
+ installer webpagereplay.Installer
cmd cli.Command
}
@@ -191,6 +192,22 @@ func (r *ReplayCommand) Flags() []cli.Flag {
})
}
+func (r *RootCACommand) Flags() []cli.Flag {
+ return append(r.certConfig.Flags(),
+ cli.StringFlag{
+ Name: "android_device_id",
+ Value: "",
+ Usage: "Device id of an android device. Only relevant for Android",
+ Destination: &r.installer.AndroidDeviceId,
+ },
+ cli.StringFlag{
+ Name: "adb_binary_path",
+ Value: "adb",
+ Usage: "Path to adb binary. Only relevant for Android",
+ Destination: &r.installer.AdbBinaryPath,
+ })
+}
+
func getListener(port int) (net.Listener, error) {
addr, err := net.ResolveTCPAddr("tcp", fmt.Sprintf("localhost:%d", port))
if err != nil {
@@ -358,21 +375,14 @@ func (r *ReplayCommand) Run(c *cli.Context) {
}
func (r *RootCACommand) Install(c *cli.Context) {
- log.Printf("Loading cert from %v\n", r.certConfig.certFile)
- log.Printf("Loading key from %v\n", r.certConfig.keyFile)
- root_cert, err := tls.LoadX509KeyPair(r.certConfig.certFile, r.certConfig.keyFile)
- if err != nil {
- fmt.Fprintf(os.Stderr, "error opening cert or key files: %v", err)
- os.Exit(1)
- }
- err = webpagereplay.InstallRoot(root_cert.Certificate[0])
- if err != nil {
+ if err := r.installer.InstallRoot(r.certConfig.certFile, r.certConfig.keyFile); err != nil {
fmt.Fprintf(os.Stderr, "Install root failed: %v", err)
+ os.Exit(1)
}
}
func (r *RootCACommand) Remove(c *cli.Context) {
- webpagereplay.RemoveRoot()
+ r.installer.RemoveRoot()
}
func main() {
@@ -402,13 +412,14 @@ func main() {
installroot.cmd = cli.Command{
Name: "installroot",
Usage: "Install a test root CA",
- Flags: installroot.certConfig.Flags(),
+ Flags: installroot.Flags(),
Action: installroot.Install,
}
removeroot.cmd = cli.Command{
Name: "removeroot",
Usage: "Remove a test root CA",
+ Flags: removeroot.Flags(),
Action: removeroot.Remove,
}
« no previous file with comments | « web_page_replay_go/src/webpagereplay/installroot.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698