LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // Package tls partially implements the TLS 1.1 protocol, as specified in RFC | 5 // Package tls partially implements the TLS 1.1 protocol, as specified in RFC |
6 // 4346. | 6 // 4346. |
7 package tls | 7 package tls |
8 | 8 |
9 import ( | 9 import ( |
10 "crypto/rsa" | 10 "crypto/rsa" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 conn := Client(c, config) | 113 conn := Client(c, config) |
114 if err = conn.Handshake(); err != nil { | 114 if err = conn.Handshake(); err != nil { |
115 c.Close() | 115 c.Close() |
116 return nil, err | 116 return nil, err |
117 } | 117 } |
118 return conn, nil | 118 return conn, nil |
119 } | 119 } |
120 | 120 |
121 // LoadX509KeyPair reads and parses a public/private key pair from a pair of | 121 // LoadX509KeyPair reads and parses a public/private key pair from a pair of |
122 // files. The files must contain PEM encoded data. | 122 // files. The files must contain PEM encoded data. |
123 func LoadX509KeyPair(certFile string, keyFile string) (cert Certificate, err err
or) { | 123 func LoadX509KeyPair(certFile, keyFile string) (cert Certificate, err error) { |
124 certPEMBlock, err := ioutil.ReadFile(certFile) | 124 certPEMBlock, err := ioutil.ReadFile(certFile) |
125 if err != nil { | 125 if err != nil { |
126 return | 126 return |
127 } | 127 } |
128 keyPEMBlock, err := ioutil.ReadFile(keyFile) | 128 keyPEMBlock, err := ioutil.ReadFile(keyFile) |
129 if err != nil { | 129 if err != nil { |
130 return | 130 return |
131 } | 131 } |
132 return X509KeyPair(certPEMBlock, keyPEMBlock) | 132 return X509KeyPair(certPEMBlock, keyPEMBlock) |
133 } | 133 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 return | 183 return |
184 } | 184 } |
185 | 185 |
186 if x509Cert.PublicKeyAlgorithm != x509.RSA || x509Cert.PublicKey.(*rsa.P
ublicKey).N.Cmp(key.PublicKey.N) != 0 { | 186 if x509Cert.PublicKeyAlgorithm != x509.RSA || x509Cert.PublicKey.(*rsa.P
ublicKey).N.Cmp(key.PublicKey.N) != 0 { |
187 err = errors.New("crypto/tls: private key does not match public
key") | 187 err = errors.New("crypto/tls: private key does not match public
key") |
188 return | 188 return |
189 } | 189 } |
190 | 190 |
191 return | 191 return |
192 } | 192 } |
LEFT | RIGHT |