| 952 | |
| 953 | #[pygetset(setter)] |
| 954 | fn set_options(&self, value: i32, vm: &VirtualMachine) -> PyResult<()> { |
| 955 | // Validate that the value is non-negative |
| 956 | if value < 0 { |
| 957 | return Err(vm.new_value_error("options must be non-negative")); |
| 958 | } |
| 959 | |
| 960 | // Deprecated SSL/TLS protocol version options |
| 961 | let opt_no = OP_NO_SSLv2 |
| 962 | | OP_NO_SSLv3 |
| 963 | | OP_NO_TLSv1 |
| 964 | | OP_NO_TLSv1_1 |
| 965 | | OP_NO_TLSv1_2 |
| 966 | | OP_NO_TLSv1_3; |
| 967 | |
| 968 | // Get current options and calculate newly set bits |
| 969 | let old_opts = *self.options.read(); |
| 970 | let set = !old_opts & value; // Bits being newly set |
| 971 | |
| 972 | // Warn if any deprecated options are being newly set |
| 973 | if (set & opt_no) != 0 { |
| 974 | _warnings::warn( |
| 975 | vm.ctx.exceptions.deprecation_warning, |
| 976 | "ssl.OP_NO_SSL*/ssl.OP_NO_TLS* options are deprecated".to_owned(), |
| 977 | 2, // stack_level = 2 |
| 978 | vm, |
| 979 | )?; |
| 980 | } |
| 981 | |
| 982 | *self.options.write() = value; |
| 983 | Ok(()) |
| 984 | } |
| 985 | |
| 986 | #[pygetset] |
| 987 | fn minimum_version(&self) -> i32 { |