Move protocol and client into Python modules

Shuffle files around in an initial attempt of creating trustify,
trustify.protocol and trustify.client Python modules. The reference
implemntation of the server remains where it was for now.
This commit is contained in:
Faidon Liambotis 2012-08-12 07:49:18 +03:00
parent 33c51bf825
commit b8d3aab7a5
19 changed files with 30 additions and 49 deletions

2
.gitignore vendored
View file

@ -1,3 +1,3 @@
*.pyc
chocolate_protocol_pb2.py
trustify/protocol/chocolate_pb2.py
m3

View file

@ -1,10 +0,0 @@
In this directory are tools that will run on webservers for sysadmins to
automatically obtain their certs
Set CHOCOLATESERVER environment variable for client.py, or pass the server
name as a command line argument!
client.py - experimental tool for making requests and parsing replies
configurator.py - edits Apache config files using Augeas
sni_challenge.py - sets up the Apache server for the DV SNI cert challenge

View file

@ -1 +0,0 @@
../server-ca/hashcash.py

6
client.py Normal file
View file

@ -0,0 +1,6 @@
#!/usr/bin/env python
from trustify.client import client
if __name__ == "__main__":
client.authenticate()

View file

@ -4,9 +4,5 @@
# rsync -av --delete sni_challenge demoCA ${CHOCOLATESERVER}:
# ssh ${CHOCOLATESERVER} make -C sni_challenge clean all
chocolate_protocol_pb2.py: chocolate_protocol.proto
protoc chocolate_protocol.proto --python_out=.
cp -p chocolate_protocol_pb2.py ../client-webserver/
clean:
rm -f *.pyc

View file

@ -2,10 +2,10 @@
import web, redis, time, binascii, re, urllib2
import CSR
import hashcash
from trustify.protocol import hashcash
from CSR import M2Crypto
from Crypto import Random
from chocolate_protocol_pb2 import chocolatemessage
from trustify.protocol.chocolate_pb2 import chocolatemessage
from google.protobuf.message import DecodeError
from CONFIG import chocolate_server_name, min_keysize, difficulty, polldelay

0
trustify/__init__.py Normal file
View file

View file

View file

@ -1,25 +1,19 @@
#!/usr/bin/env python
from chocolate_protocol_pb2 import chocolatemessage
import M2Crypto
# It is OK to use the upstream M2Crypto here instead of our modified
# version.
import urllib2, os, grp, pwd, sys, time, random, sys, hashlib, subprocess
import urllib2
import os, grp, pwd, sys, time, random, sys
import hashlib
import subprocess
import getopt
# TODO: support a mode where use of interactive prompting is forbidden
import sni_challenge
import configurator
#from trustify import sni_challenge
#from trustify import configurator
# bits of hashcash to generate
from CONFIG import difficulty
#from trustify.CONFIG import difficulty
#Trustify certificate and chain files
from CONFIG import cert_file, chain_file
#from trustify.CONFIG import cert_file, chain_file
from trustify.protocol.chocolate_pb2 import chocolatemessage
from trustify.client import sni_challenge
from trustify.client import configurator
from trustify.client.CONFIG import difficulty, cert_file, chain_file
# it's weird to point to chocolate servers via raw IPv6 addresses, and such
# addresses can be %SCARY in some contexts, so out of paranoia let's disable
@ -314,7 +308,4 @@ def authenticate():
print "Server reported failure."
sys.exit(1)
# vim: set expandtab tabstop=4 shiftwidth=4
if __name__ == "__main__":
authenticate()
# vim: set expandtab tabstop=4 shiftwidth=4

View file

@ -5,8 +5,7 @@ import os
import sys
import socket
from CONFIG import SERVER_ROOT, CONFIG_DIR
#from trustify.CONFIG import SERVER_ROOT
from trustify.client.CONFIG import SERVER_ROOT
class VH(object):
def __init__(self, vh_path, vh_addrs):

View file

@ -10,18 +10,11 @@ from os import remove, close, path
import binascii
import augeas
import configurator
#from trustify import configurator
from CONFIG import CONFIG_DIR, WORK_DIR, SERVER_ROOT
from CONFIG import CHOC_CERT_CONF, OPTIONS_SSL_CONF, APACHE_CHALLENGE_CONF
from CONFIG import S_SIZE, NONCE_SIZE
#Once directory changes to trustify and becomes package
#from trustify.CONFIG import CONFIG_DIR, WORK_DIR, SERVER_ROOT
#from trustify.CONFIG import CHOC_CERT_CONF, OPTIONS_SSL_CONF
#from trustify.CONFIG import APACHE_CHALLENGE_CONF
#from trustify.CONFIG import S_SIZE, NONCE_SIZE
from trustify.client import configurator
from trustify.client.CONFIG import CONFIG_DIR, WORK_DIR, SERVER_ROOT
from trustify.client.CONFIG import CHOC_CERT_CONF, OPTIONS_SSL_CONF, APACHE_CHALLENGE_CONF
from trustify.client.CONFIG import S_SIZE, NONCE_SIZE
def getChocCertFile(nonce):
"""

View file

@ -0,0 +1,7 @@
proto = chocolate.proto
$(proto:.proto=_pb2.py): $(proto)
protoc $^ --python_out=.
clean:
rm -f *_pb2.py *_pb2.pyc

View file