File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -564,6 +564,32 @@ impl PySslContext {
564564 SslServerOrClient :: Client
565565 } ;
566566
567+ if let Some ( hostname) = & args. server_hostname {
568+ let hostname = hostname. borrow_value ( ) ;
569+ if hostname. is_empty ( ) || hostname. starts_with ( '.' ) {
570+ return Err ( vm. new_value_error (
571+ "server_hostname cannot be an empty string or start with a leading dot."
572+ . to_owned ( ) ,
573+ ) ) ;
574+ }
575+ let ip = hostname. parse :: < std:: net:: IpAddr > ( ) ;
576+ if ip. is_err ( ) {
577+ ssl. set_hostname ( hostname)
578+ . map_err ( |e| convert_openssl_error ( vm, e) ) ?;
579+ }
580+ if zelf. check_hostname . load ( ) {
581+ if let Ok ( ip) = ip {
582+ ssl. param_mut ( )
583+ . set_ip ( ip)
584+ . map_err ( |e| convert_openssl_error ( vm, e) ) ?;
585+ } else {
586+ ssl. param_mut ( )
587+ . set_host ( hostname)
588+ . map_err ( |e| convert_openssl_error ( vm, e) ) ?;
589+ }
590+ }
591+ }
592+
567593 let stream = ssl:: SslStream :: new ( ssl, args. sock . clone ( ) )
568594 . map_err ( |e| convert_openssl_error ( vm, e) ) ?;
569595
You can’t perform that action at this time.
0 commit comments