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 // This package partially implements the TLS 1.1 protocol, as specified in RFC 4
346. | 5 // This package partially implements the TLS 1.1 protocol, as specified in RFC 4
346. |
6 package tls | 6 package tls |
7 | 7 |
8 import ( | 8 import ( |
9 "crypto/rsa" | 9 "crypto/rsa" |
10 "crypto/x509" | 10 "crypto/x509" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 } | 80 } |
81 return NewListener(l, config), nil | 81 return NewListener(l, config), nil |
82 } | 82 } |
83 | 83 |
84 // Dial connects to the given network address using net.Dial | 84 // Dial connects to the given network address using net.Dial |
85 // and then initiates a TLS handshake, returning the resulting | 85 // and then initiates a TLS handshake, returning the resulting |
86 // TLS connection. | 86 // TLS connection. |
87 // Dial interprets a nil configuration as equivalent to | 87 // Dial interprets a nil configuration as equivalent to |
88 // the zero configuration; see the documentation of Config | 88 // the zero configuration; see the documentation of Config |
89 // for the defaults. | 89 // for the defaults. |
90 func Dial(network, laddr, raddr string, config *Config) (*Conn, os.Error) { | 90 func Dial(network, addr string, config *Config) (*Conn, os.Error) { |
91 » c, err := net.Dial(network, laddr, raddr) | 91 » raddr := addr |
| 92 » c, err := net.Dial(network, raddr) |
92 if err != nil { | 93 if err != nil { |
93 return nil, err | 94 return nil, err |
94 } | 95 } |
95 | 96 |
96 colonPos := strings.LastIndex(raddr, ":") | 97 colonPos := strings.LastIndex(raddr, ":") |
97 if colonPos == -1 { | 98 if colonPos == -1 { |
98 colonPos = len(raddr) | 99 colonPos = len(raddr) |
99 } | 100 } |
100 hostname := raddr[:colonPos] | 101 hostname := raddr[:colonPos] |
101 | 102 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 return | 167 return |
167 } | 168 } |
168 | 169 |
169 if x509Cert.PublicKeyAlgorithm != x509.RSA || x509Cert.PublicKey.(*rsa.P
ublicKey).N.Cmp(key.PublicKey.N) != 0 { | 170 if x509Cert.PublicKeyAlgorithm != x509.RSA || x509Cert.PublicKey.(*rsa.P
ublicKey).N.Cmp(key.PublicKey.N) != 0 { |
170 err = os.ErrorString("crypto/tls: private key does not match pub
lic key") | 171 err = os.ErrorString("crypto/tls: private key does not match pub
lic key") |
171 return | 172 return |
172 } | 173 } |
173 | 174 |
174 return | 175 return |
175 } | 176 } |
LEFT | RIGHT |