| 142 | class SSLWSGIServerMixin: |
| 143 | |
| 144 | def finish_request(self, request, client_address): |
| 145 | # The relative location of our test directory (which |
| 146 | # contains the ssl key and certificate files) differs |
| 147 | # between the stdlib and stand-alone asyncio. |
| 148 | # Prefer our own if we can find it. |
| 149 | context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) |
| 150 | context.load_cert_chain(ONLYCERT, ONLYKEY) |
| 151 | |
| 152 | ssock = context.wrap_socket(request, server_side=True) |
| 153 | try: |
| 154 | self.RequestHandlerClass(ssock, client_address, self) |
| 155 | ssock.close() |
| 156 | except OSError: |
| 157 | # maybe socket has been closed by peer |
| 158 | pass |
| 159 | |
| 160 | |
| 161 | class SSLWSGIServer(SSLWSGIServerMixin, SilentWSGIServer): |