def do_show(self, arguments): """show SSL configuration information""" provider = Provider() if provider.key_material_exists(): print "SSL has been provisioned:" print " SSL Key:", provider.key_exists() and "EXISTS" or "MISSING" print " SSL Certificate:", provider.certificate_exists() and "EXISTS" or "MISSING" print " Key Pair:", provider.key_material_valid() and "VALID" or "INVALID" else: print "SSL has not been provisioned."
def do_create(self, arguments): """create some new key material""" provider = Provider() if arguments.type == "ca": self.__create_ca(provider, arguments) elif arguments.type == "keypair": self.__create_keypair(provider, arguments) elif arguments.type == "truststore": provider.make_bks_trust_store() else: print "Unexpected type:", arguments.type
def __init__(self, arguments, trust_callback=None): Transport.__init__(self) self.__socket = socket.socket() if arguments.ssl: provider = Provider() self.__socket = ssl.wrap_socket( self.__socket, cert_reqs=ssl.CERT_REQUIRED, ca_certs=provider.ca_certificate_path()) self.__socket.settimeout(90.0) self.__socket.connect(self.__getEndpoint(arguments)) if arguments.ssl: trust_callback(provider, self.__socket.getpeercert(True), self.__socket.getpeername())
def __init__(self, arguments, trust_callback=None): Transport.__init__(self) self.__socket = socket.socket() if arguments.ssl: provider = Provider() self.__socket = ssl.wrap_socket(self.__socket, cert_reqs=ssl.CERT_REQUIRED, ca_certs=provider.ca_certificate_path()) self.__socket.settimeout(90.0) self.__socket.connect(self.__getEndpoint(arguments)) if arguments.ssl: trust_callback(provider, self.__socket.getpeercert(True), self.__socket.getpeername())
"--ssl", action=store_zero_or_two(), help="enable SSL, optionally specifying the key and certificate", nargs="*") arguments = parser.parse_args(sys.argv[2::]) if arguments.log != None: logger.addFileHandler(arguments.log) task.LoopingCall(heartbeat).start(arguments.ping_interval) if arguments.ssl != None: print "Starting Mercury server, listening on 0.0.0.0:%d (with SSL)" % arguments.port if arguments.ssl == []: print "Using default SSL key material..." arguments.ssl = Provider().get_keypair("mercury-server") internet.reactor.listenSSL( arguments.port, DroidHgServer(not arguments.no_http), ssl.DefaultOpenSSLContextFactory(*arguments.ssl)) else: print "Starting Mercury server, listening on 0.0.0.0:%d" % arguments.port internet.reactor.listenTCP(arguments.port, DroidHgServer(not arguments.no_http)) internet.reactor.run()