Skip to content

Commit 9db27e9

Browse files
authored
Forwarding machine: fix and doc (#4823)
* Fix writing cert to disk in fwdmachine a Cert object's pem property is a str, returned by der2pem(). Opening an output file in binary mode then trying to write a str to it results in a stacktrace. * Fix ForwardMachine documentation
1 parent b5ebda1 commit 9db27e9

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

scapy/fwdmachine.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,10 @@ class ForwardMachine:
8686
Methods to override:
8787
8888
:func xfrmcs: a function to call when forwarding a packet from the 'client' to
89-
the server. If it returns True, the packet is forwarded as it. If it
90-
returns False or None, the packet is discarded. If it returns a
91-
packet, this packet is forwarded instead of the original packet.
89+
the server. If it raises a FORWARD exception, the packet is forwarded as it. If
90+
it raises a DROP Exception, the packet is discarded. If it raises a
91+
FORWARD_REPLACE(pkt) exception, then pkt is forwarded instead of the original
92+
packet.
9293
:func xfrmsc: same as xfrmcs for packets forwarded from the 'server' to the
9394
'client'.
9495
"""
@@ -372,7 +373,7 @@ def cb_sni(sock, server_name, _):
372373
# Load result certificate our SSL server
373374
# (this is dumb but we need to store them on disk)
374375
certfile = get_temp_file()
375-
with open(certfile, "wb") as fd:
376+
with open(certfile, "w") as fd:
376377
for c in certs:
377378
fd.write(c.pem)
378379
keyfile = get_temp_file()

0 commit comments

Comments
 (0)