aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2011-02-16 23:09:42 +1300
committerAldo Cortesi <aldo@nullcube.com>2011-02-16 23:09:42 +1300
commitd9374ff97b07eb517d36aca8f81c3d6a7c7d93cc (patch)
treeeef37026b9fb6ff37b69451cc44904cb03f4e554
parentf5511350eb383a2d2d73c6d1ae328f6eb00f501f (diff)
downloadmitmproxy-d9374ff97b07eb517d36aca8f81c3d6a7c7d93cc.tar.gz
mitmproxy-d9374ff97b07eb517d36aca8f81c3d6a7c7d93cc.tar.bz2
mitmproxy-d9374ff97b07eb517d36aca8f81c3d6a7c7d93cc.zip
Extract common SSL certificate options into a group.
Use this only in mitmdump and mitmproxy for now.
-rw-r--r--libmproxy/utils.py29
-rwxr-xr-xmitmdump21
-rwxr-xr-xmitmproxy26
3 files changed, 31 insertions, 45 deletions
diff --git a/libmproxy/utils.py b/libmproxy/utils.py
index 39279e04..ffa3216a 100644
--- a/libmproxy/utils.py
+++ b/libmproxy/utils.py
@@ -13,6 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import re, os, subprocess, datetime, textwrap, errno
+import optparse
def format_timestamp(s):
d = datetime.datetime.fromtimestamp(s)
@@ -474,6 +475,7 @@ def make_bogus_cert(certpath, countryName=None, stateOrProvinceName=None, locali
stdin=subprocess.PIPE
)
+
def mkdir_p(path):
try:
os.makedirs(path)
@@ -483,3 +485,30 @@ def mkdir_p(path):
else:
raise
+
+def certificate_option_group(parser):
+ group = optparse.OptionGroup(parser, "SSL")
+ group.add_option(
+ "--cert", action="store",
+ type = "str", dest="cert", default="~/.mitmproxy/default.pem",
+ help = "SSL certificate file."
+ )
+ group.add_option(
+ "-c", "--cacert", action="store",
+ type = "str", dest="cacert", default="~/.mitmproxy/ca.pem",
+ help = "SSL CA certificate file."
+ )
+ group.add_option(
+ "--certpath", action="store",
+ type = "str", dest="certpath", default="~/.mitmproxy/",
+ help = "SSL certificate store path."
+ )
+ group.add_option(
+ "--ciphers", action="store",
+ type = "str", dest="ciphers", default=None,
+ help = "SSL ciphers."
+ )
+ parser.add_option_group(group)
+
+
+
diff --git a/mitmdump b/mitmdump
index c0ed7dfe..ee00bd92 100755
--- a/mitmdump
+++ b/mitmdump
@@ -26,26 +26,7 @@ if __name__ == '__main__':
usage = "%prog [options]",
version="%%prog %s"%VERSION,
)
- parser.add_option(
- "--cert", action="store",
- type = "str", dest="cert", default="~/.mitmproxy/default.pem",
- help = "SSL certificate file."
- )
- parser.add_option(
- "-c", "--cacert", action="store",
- type = "str", dest="cacert", default="~/.mitmproxy/ca.pem",
- help = "SSL CA certificate file."
- )
- parser.add_option(
- "--certpath", action="store",
- type = "str", dest="certpath", default="~/.mitmproxy/",
- help = "SSL certificate store path."
- )
- parser.add_option(
- "--ciphers", action="store",
- type = "str", dest="ciphers", default=None,
- help = "SSL ciphers."
- )
+ utils.certificate_option_group(parser)
parser.add_option(
"-p", "--port", action="store",
type = "int", dest="port", default=8080,
diff --git a/mitmproxy b/mitmproxy
index cf746e38..c9d52d79 100755
--- a/mitmproxy
+++ b/mitmproxy
@@ -26,7 +26,7 @@ if __name__ == '__main__':
usage = "%prog [options] [flowdump path]",
version="%%prog %s"%VERSION,
)
-
+ utils.certificate_option_group(parser)
parser.add_option(
"-a", "--addr", action="store",
type = "str", dest="addr", default='',
@@ -34,30 +34,6 @@ if __name__ == '__main__':
)
parser.add_option(
- "--cert", action="store",
- type = "str", dest="cert", default="~/.mitmproxy/default.pem",
- help = "SSL certificate file."
- )
-
- parser.add_option(
- "-c", "--cacert", action="store",
- type = "str", dest="cacert", default="~/.mitmproxy/ca.pem",
- help = "SSL CA certificate file."
- )
-
- parser.add_option(
- "--certpath", action="store",
- type = "str", dest="certpath", default="~/.mitmproxy/",
- help = "SSL certificate store path."
- )
-
- parser.add_option(
- "--ciphers", action="store",
- type = "str", dest="ciphers", default=None,
- help = "SSL ciphers."
- )
-
- parser.add_option(
"-p", "--port", action="store",
type = "int", dest="port", default=8080,
help = "Port."