Merge pull request #7270 from tstromberg/cerrt-err

Add more debugging for certificate issues
pull/7295/head
Medya Ghazizadeh 2020-03-27 22:16:48 -07:00 committed by GitHub
commit 356e203ed4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -117,6 +117,7 @@ func SetupCerts(cmd command.Runner, k8s config.KubernetesConfig, n config.Node)
}
for _, f := range copyableFiles {
glog.Infof("copying: %s/%s", f.GetTargetDir(), f.GetTargetName())
if err := cmd.Copy(f); err != nil {
return nil, errors.Wrapf(err, "Copy %s", f.GetAssetName())
}
@ -325,6 +326,7 @@ func collectCACerts() (map[string]string, error) {
if info != nil && !info.IsDir() {
ext := strings.ToLower(filepath.Ext(hostpath))
if ext == ".crt" || ext == ".pem" {
glog.Infof("found cert: %s (%d bytes)", info.Name(), info.Size())
validPem, err := isValidPEMCertificate(hostpath)
if err != nil {
return err
@ -360,9 +362,16 @@ func collectCACerts() (map[string]string, error) {
// getSubjectHash calculates Certificate Subject Hash for creating certificate symlinks
func getSubjectHash(cr command.Runner, filePath string) (string, error) {
lrr, err := cr.RunCmd(exec.Command("ls", "-la", filePath))
if err != nil {
return "", err
}
glog.Infof("hashing: %s", lrr.Stdout.String())
rr, err := cr.RunCmd(exec.Command("openssl", "x509", "-hash", "-noout", "-in", filePath))
if err != nil {
return "", errors.Wrapf(err, rr.Command())
crr, _ := cr.RunCmd(exec.Command("cat", filePath))
return "", errors.Wrapf(err, "cert:\n%s\n---\n%s", lrr.Output(), crr.Stdout.String())
}
stringHash := strings.TrimSpace(rr.Stdout.String())
return stringHash, nil