| 535 | ) |
| 536 | |
| 537 | def set_npn_protocols(self, npn_protocols): |
| 538 | warnings.warn( |
| 539 | "ssl NPN is deprecated, use ALPN instead", |
| 540 | DeprecationWarning, |
| 541 | stacklevel=2 |
| 542 | ) |
| 543 | protos = bytearray() |
| 544 | for protocol in npn_protocols: |
| 545 | b = bytes(protocol, 'ascii') |
| 546 | if len(b) == 0 or len(b) > 255: |
| 547 | raise SSLError('NPN protocols must be 1 to 255 in length') |
| 548 | protos.append(len(b)) |
| 549 | protos.extend(b) |
| 550 | |
| 551 | self._set_npn_protocols(protos) |
| 552 | |
| 553 | def set_servername_callback(self, server_name_callback): |
| 554 | if server_name_callback is None: |