| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package webpagereplay | 5 package webpagereplay |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bytes" | 8 "bytes" |
| 9 "fmt" | 9 "fmt" |
| 10 "io/ioutil" | 10 "io/ioutil" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 // Runs the adb shell command. | 45 // Runs the adb shell command. |
| 46 func (i *Installer) adbShell(args ...string) error { | 46 func (i *Installer) adbShell(args ...string) error { |
| 47 shellArgs := append([]string{"shell"}, args...) | 47 shellArgs := append([]string{"shell"}, args...) |
| 48 return i.adb(shellArgs...) | 48 return i.adb(shellArgs...) |
| 49 } | 49 } |
| 50 | 50 |
| 51 // The issuer hash is used as filename for the installed cert. | 51 // The issuer hash is used as filename for the installed cert. |
| 52 func getIssuerHashFileName(certPath string) (string, error) { | 52 func getIssuerHashFileName(certPath string) (string, error) { |
| 53 cmd := exec.Command("openssl", "x509", "-in", certPath, "-issuer_hash_ol
d", "-noout") | 53 cmd := exec.Command("openssl", "x509", "-in", certPath, "-issuer_hash_ol
d", "-noout") |
| 54 var out bytes.Buffer | 54 var out bytes.Buffer |
| 55 var stderr bytes.Buffer |
| 55 cmd.Stdout = &out | 56 cmd.Stdout = &out |
| 57 cmd.Stderr = &stderr |
| 56 err := cmd.Run() | 58 err := cmd.Run() |
| 57 if err != nil { | 59 if err != nil { |
| 58 » » return "", err | 60 » » return "", fmt.Errorf("%v : %s", err, stderr.String()) |
| 59 } | 61 } |
| 60 fmt.Print(out.String()) | 62 fmt.Print(out.String()) |
| 61 return strings.Trim(out.String(), "\r\n") + ".0", nil | 63 return strings.Trim(out.String(), "\r\n") + ".0", nil |
| 62 } | 64 } |
| 63 | 65 |
| 64 // Formats the cert and returns the formatted cert. | 66 // Formats the cert and returns the formatted cert. |
| 65 func formatCert(certPath string) (string, error) { | 67 func formatCert(certPath string) (string, error) { |
| 66 cmd := exec.Command("openssl", "x509", "-inform", "PEM", "-text", "-in",
certPath) | 68 cmd := exec.Command("openssl", "x509", "-inform", "PEM", "-text", "-in",
certPath) |
| 67 var out bytes.Buffer | 69 var out bytes.Buffer |
| 68 cmd.Stdout = &out | 70 cmd.Stdout = &out |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 func (i *Installer) AdbUninstallRoot() error { | 114 func (i *Installer) AdbUninstallRoot() error { |
| 113 var err error | 115 var err error |
| 114 if err = i.adbShell("umount", androidSystemCertDir); err != nil { | 116 if err = i.adbShell("umount", androidSystemCertDir); err != nil { |
| 115 return err | 117 return err |
| 116 } | 118 } |
| 117 if err = i.adbShell("rm", "-r", androidTempCertDir); err != nil { | 119 if err = i.adbShell("rm", "-r", androidTempCertDir); err != nil { |
| 118 return err | 120 return err |
| 119 } | 121 } |
| 120 return nil | 122 return nil |
| 121 } | 123 } |
| OLD | NEW |