Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(64)

Delta Between Two Patch Sets: environs/config/authkeys.go

Issue 6855054: state: add CACert to Info.
Left Patch Set: state: add RootCertPEM to Info. Created 12 years, 4 months ago
Right Patch Set: state: add CACert to Info. Created 12 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « environs/cloudinit/cloudinit_test.go ('k') | environs/config_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 package config 1 package config
2 2
3 import ( 3 import (
4 "bytes" 4 "bytes"
5 "crypto/tls" 5 "crypto/tls"
6 "crypto/x509" 6 "crypto/x509"
7 "encoding/pem" 7 "encoding/pem"
8 "fmt" 8 "fmt"
9 "io/ioutil" 9 "io/ioutil"
10 "os" 10 "os"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 firstError = fmt.Errorf("no public ssh keys found") 57 firstError = fmt.Errorf("no public ssh keys found")
58 } 58 }
59 return "", firstError 59 return "", firstError
60 } 60 }
61 return string(keyData), nil 61 return string(keyData), nil
62 } 62 }
63 63
64 // verifyKeyPair verifies that the certificate and key parse correctly. 64 // verifyKeyPair verifies that the certificate and key parse correctly.
65 // The key is optional - if it is provided, we also check that the key 65 // The key is optional - if it is provided, we also check that the key
66 // matches the certificate. 66 // matches the certificate.
67 func verifyKeyPair(certPEM, keyPEM []byte) error { 67 func verifyKeyPair(cert, key []byte) error {
68 » if keyPEM != nil { 68 » if key != nil {
69 » » _, err := tls.X509KeyPair(certPEM, keyPEM) 69 » » _, err := tls.X509KeyPair(cert, key)
70 return err 70 return err
71 } 71 }
72 » for len(certPEM) > 0 { 72 » for len(cert) > 0 {
73 var certBlock *pem.Block 73 var certBlock *pem.Block
74 » » certBlock, certPEM = pem.Decode(certPEM) 74 » » certBlock, cert = pem.Decode(cert)
75 if certBlock == nil { 75 if certBlock == nil {
76 break 76 break
77 } 77 }
78 if certBlock.Type == "CERTIFICATE" { 78 if certBlock.Type == "CERTIFICATE" {
79 _, err := x509.ParseCertificate(certBlock.Bytes) 79 _, err := x509.ParseCertificate(certBlock.Bytes)
80 return err 80 return err
81 } 81 }
82 } 82 }
83 return fmt.Errorf("no certificates found") 83 return fmt.Errorf("no certificates found")
84 } 84 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b