@@ -80,6 +80,22 @@ func Dial(network, addr string, ctx *Ctx, flags DialFlags) (*Conn, error) {
8080 return DialSession (network , addr , ctx , flags , nil )
8181}
8282
83+ // DialWithDialer will connect to network/address and then wrap the corresponding
84+ // underlying connection with an OpenSSL client connection using context ctx.
85+ // If flags includes InsecureSkipHostVerification, the server certificate's
86+ // hostname will not be checked to match the hostname in addr. Otherwise, flags
87+ // should be 0.
88+ //
89+ // The specified dialer will be used to open the underlying TCP connection.
90+ //
91+ // Dial probably won't work for you unless you set a verify location or add
92+ // some certs to the certificate store of the client context you're using.
93+ // This library is not nice enough to use the system certificate store by
94+ // default for you yet.
95+ func DialWithDialer (dialer * net.Dialer , network , addr string , ctx * Ctx , flags DialFlags ) (* Conn , error ) {
96+ return DialSessionWithDialer (dialer , network , addr , ctx , flags , nil )
97+ }
98+
8399// DialSession will connect to network/address and then wrap the corresponding
84100// underlying connection with an OpenSSL client connection using context ctx.
85101// If flags includes InsecureSkipHostVerification, the server certificate's
@@ -93,7 +109,26 @@ func Dial(network, addr string, ctx *Ctx, flags DialFlags) (*Conn, error) {
93109//
94110// If session is not nil it will be used to resume the tls state. The session
95111// can be retrieved from the GetSession method on the Conn.
96- func DialSession (network , addr string , ctx * Ctx , flags DialFlags ,
112+ func DialSession (network , addr string , ctx * Ctx , flags DialFlags , session []byte ) (* Conn , error ) {
113+ return DialSessionWithDialer (nil , network , addr , ctx , flags , session )
114+ }
115+
116+ // DialSessionWithDialer will connect to network/address and then wrap the corresponding
117+ // underlying connection with an OpenSSL client connection using context ctx.
118+ // If flags includes InsecureSkipHostVerification, the server certificate's
119+ // hostname will not be checked to match the hostname in addr. Otherwise, flags
120+ // should be 0.
121+ //
122+ // The specified dialer will be used to open the underlying TCP connection.
123+ //
124+ // Dial probably won't work for you unless you set a verify location or add
125+ // some certs to the certificate store of the client context you're using.
126+ // This library is not nice enough to use the system certificate store by
127+ // default for you yet.
128+ //
129+ // If session is not nil it will be used to resume the tls state. The session
130+ // can be retrieved from the GetSession method on the Conn.
131+ func DialSessionWithDialer (dialer * net.Dialer , network , addr string , ctx * Ctx , flags DialFlags ,
97132 session []byte ) (* Conn , error ) {
98133
99134 host , _ , err := net .SplitHostPort (addr )
@@ -108,7 +143,12 @@ func DialSession(network, addr string, ctx *Ctx, flags DialFlags,
108143 }
109144 // TODO: use operating system default certificate chain?
110145 }
111- c , err := net .Dial (network , addr )
146+ var c net.Conn
147+ if dialer == nil {
148+ c , err = net .Dial (network , addr )
149+ } else {
150+ c , err = dialer .Dial (network , addr )
151+ }
112152 if err != nil {
113153 return nil , err
114154 }
0 commit comments