Skip to content

Commit 51b158b

Browse files
slozierslide
authored andcommitted
Use server_hostname (#496)
1 parent a06b29e commit 51b158b

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

Src/IronPython.Modules/_socket.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2438,6 +2438,7 @@ public class ssl {
24382438
private readonly CodeContext _context;
24392439
private readonly RemoteCertificateValidationCallback _callback;
24402440
private Exception _validationFailure;
2441+
internal string _serverHostName;
24412442

24422443
public ssl(CodeContext context, PythonSocket.socket sock, string keyfile=null, string certfile=null, X509Certificate2Collection certs=null) {
24432444
_context = context;
@@ -2640,7 +2641,7 @@ public void do_handshake() {
26402641
if (_cert != null) {
26412642
collection.Add(_cert);
26422643
}
2643-
_sslStream.AuthenticateAsClient(_socket._hostName, collection, enabledSslProtocols, false);
2644+
_sslStream.AuthenticateAsClient(_serverHostName ?? _socket._hostName, collection, enabledSslProtocols, false);
26442645
}
26452646
} catch (AuthenticationException e) {
26462647
((IDisposable)_socket._socket).Dispose();

Src/IronPython.Modules/_ssl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public void load_verify_locations(CodeContext context, [DefaultParameterValue(nu
197197
}
198198

199199
public object _wrap_socket(CodeContext context, [DefaultParameterValue(null)] PythonSocket.socket sock, [DefaultParameterValue(false)] bool server_side, [DefaultParameterValue(null)] string server_hostname, [DefaultParameterValue(null)] object ssl_sock) {
200-
return new PythonSocket.ssl(context, sock, server_side, null, _cafile, verify_mode, protocol | options, null, _cert_store);
200+
return new PythonSocket.ssl(context, sock, server_side, null, _cafile, verify_mode, protocol | options, null, _cert_store) { _serverHostName = server_hostname };
201201
}
202202
}
203203

0 commit comments

Comments
 (0)