(self)
| 1144 | self.context: Optional[SSLContext] = None |
| 1145 | |
| 1146 | def get(self) -> SSLContext: |
| 1147 | if not self.context: |
| 1148 | context = ssl.create_default_context() |
| 1149 | context.check_hostname = self.check_hostname |
| 1150 | context.verify_mode = self.cert_reqs |
| 1151 | if self.include_verify_flags: |
| 1152 | for flag in self.include_verify_flags: |
| 1153 | context.verify_flags |= flag |
| 1154 | if self.exclude_verify_flags: |
| 1155 | for flag in self.exclude_verify_flags: |
| 1156 | context.verify_flags &= ~flag |
| 1157 | if self.certfile or self.keyfile: |
| 1158 | context.load_cert_chain( |
| 1159 | certfile=self.certfile, |
| 1160 | keyfile=self.keyfile, |
| 1161 | password=self.password, |
| 1162 | ) |
| 1163 | if self.ca_certs or self.ca_data or self.ca_path: |
| 1164 | context.load_verify_locations( |
| 1165 | cafile=self.ca_certs, capath=self.ca_path, cadata=self.ca_data |
| 1166 | ) |
| 1167 | if self.min_version is not None: |
| 1168 | context.minimum_version = self.min_version |
| 1169 | if self.ciphers is not None: |
| 1170 | context.set_ciphers(self.ciphers) |
| 1171 | self.context = context |
| 1172 | return self.context |
| 1173 | |
| 1174 | |
| 1175 | class UnixDomainSocketConnection(AbstractConnection): |
no outgoing calls
no test coverage detected