File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 77import asyncio
88import datetime
99import typing
10+ import ssl
1011
12+ from OpenSSL import crypto
1113from twisted .internet import reactor
1214from twisted .internet .protocol import Protocol
1315
@@ -218,7 +220,20 @@ async def connectToServer(self):
218220 self .log .error ("Failed to connect to recording host: timeout expired" )
219221
220222 def doClientTls (self ):
221- cert = self .server .tcp .transport .getPeerCertificate ()
223+ if self .state .isRedirected ():
224+ self .log .info (
225+ "Fetching certificate of the original host %(host)s:%(port)d because of NLA redirection" ,
226+ {
227+ "host" : self .state .config .targetHost ,
228+ "port" : self .state .config .targetPort ,
229+ },
230+ )
231+ pem = ssl .get_server_certificate (
232+ (self .state .config .targetHost , self .state .config .targetPort )
233+ )
234+ cert = crypto .load_certificate (crypto .FILETYPE_PEM , pem )
235+ else :
236+ cert = self .server .tcp .transport .getPeerCertificate ()
222237 if not cert :
223238 # Wait for server certificate
224239 reactor .callLater (1 , self .doClientTls )
You can’t perform that action at this time.
0 commit comments