| 750 | | |
|---|
| 751 | | def bind(family, type, proto=0): |
|---|
| 752 | | """Create (or recreate) the actual socket object.""" |
|---|
| 753 | | self.socket = socket.socket(family, type, proto) |
|---|
| 754 | | self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) |
|---|
| 755 | | if self.ssl_certificate and self.ssl_private_key: |
|---|
| 756 | | if SSL is None: |
|---|
| 757 | | raise ImportError("You must install pyOpenSSL to use HTTPS.") |
|---|
| 758 | | |
|---|
| 759 | | # See http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/442473 |
|---|
| 760 | | ctx = SSL.Context(SSL.SSLv23_METHOD) |
|---|
| 761 | | ctx.use_privatekey_file(self.ssl_private_key) |
|---|
| 762 | | ctx.use_certificate_file(self.ssl_certificate) |
|---|
| 763 | | self.socket = SSLConnection(ctx, self.socket) |
|---|
| 764 | | self.populate_ssl_environ() |
|---|
| 765 | | self.socket.bind(self.bind_addr) |
|---|
| | 824 | |
|---|
| | 825 | def bind(self, family, type, proto=0): |
|---|
| | 826 | """Create (or recreate) the actual socket object.""" |
|---|
| | 827 | self.socket = socket.socket(family, type, proto) |
|---|
| | 828 | self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) |
|---|
| | 829 | ## self.socket.setsockopt(socket.SOL_SOCKET, socket.TCP_NODELAY, 1) |
|---|
| | 830 | if self.ssl_certificate and self.ssl_private_key: |
|---|
| | 831 | if SSL is None: |
|---|
| | 832 | raise ImportError("You must install pyOpenSSL to use HTTPS.") |
|---|
| | 833 | |
|---|
| | 834 | # See http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/442473 |
|---|
| | 835 | ctx = SSL.Context(SSL.SSLv23_METHOD) |
|---|
| | 836 | ctx.use_privatekey_file(self.ssl_private_key) |
|---|
| | 837 | ctx.use_certificate_file(self.ssl_certificate) |
|---|
| | 838 | self.socket = SSLConnection(ctx, self.socket) |
|---|
| | 839 | self.populate_ssl_environ() |
|---|
| | 840 | self.socket.bind(self.bind_addr) |
|---|