def test_cert_gen(self): gen = NuclideCertificatesGenerator(tempfile.gettempdir(), 'localhost', 'test') self.verify_key_file(gen.ca_key) self.verify_cert_file(gen.ca_cert) self.verify_key_file(gen.server_key) self.verify_cert_file(gen.server_cert) self.verify_key_file(gen.client_key) self.verify_cert_file(gen.client_cert) self.assertEquals( 'localhost', NuclideCertificatesGenerator.get_common_name(gen.server_cert))
def print_json(self): output = {'version': self.get_version(), 'port': self.port, 'workspace': self.workspace} server_cert, server_key, ca = self.get_server_certificate_files() if server_cert is not None and server_key is not None and ca is not None: client_cert, client_key = self.get_client_certificate_files(ca) output['cert'] = self._read_cert_file(client_cert) output['key'] = self._read_cert_file(client_key) output['ca'] = self._read_cert_file(ca) output['hostname'] = NuclideCertificatesGenerator.get_common_name(server_cert) print(json.dumps(output))
def get_server_info(self): output = {'version': self.get_version(), 'port': self.port, 'workspace': self.workspace} output['pid'] = self._get_proc_info().get_pid() server_cert, server_key, ca = self.get_server_certificate_files() if server_cert is not None and server_key is not None and ca is not None: client_cert, client_key = self.get_client_certificate_files(ca) output['cert'] = self._read_cert_file(client_cert) output['key'] = self._read_cert_file(client_key) output['ca'] = self._read_cert_file(ca) output['hostname'] = NuclideCertificatesGenerator.get_common_name(server_cert) return output
def test_cert_gen(self): gen = NuclideCertificatesGenerator(tempfile.gettempdir(), 'localhost', 'test') self.verify_key_file(gen.ca_key) self.verify_cert_file(gen.ca_cert) self.verify_key_file(gen.server_key) self.verify_cert_file(gen.server_cert) self.verify_key_file(gen.client_key) self.verify_cert_file(gen.client_cert) self.assertEquals( 'localhost', NuclideCertificatesGenerator.get_common_name(gen.server_cert))
def get_version(self): # Return version if it is cached. if self._version is not None: return self._version if self.is_https(): server_cert, server_key, ca = self.get_server_certificate_files() client_cert, client_key = self.get_client_certificate_files(ca) common_name = NuclideCertificatesGenerator.get_common_name(server_cert) self._version = utils.http_get(common_name, self.port, method='POST', url='/heartbeat', key_file=client_key, cert_file=client_cert, ca_cert=ca) else: self._version = utils.http_get('localhost', self.port, method='POST', url='/heartbeat') return self._version
def get_version(self): # Return version if it is cached. if self._version is not None: return self._version if self.is_https(): server_cert, server_key, ca = self.get_server_certificate_files() client_cert, client_key = self.get_client_certificate_files(ca) common_name = NuclideCertificatesGenerator.get_common_name(server_cert) self._version = utils.http_get(common_name, self.port, method='POST', url='/heartbeat', key_file=client_key, cert_file=client_cert, ca_cert=ca) else: self._version = utils.http_get('localhost', self.port, method='POST', url='/heartbeat') return self._version
def get_common_name(self): server_cert, _, _ = self.get_server_certificate_files() if server_cert is not None: return NuclideCertificatesGenerator.get_common_name(server_cert) else: return None
def get_common_name(self): server_cert, _, _ = self.get_server_certificate_files() if server_cert is not None: return NuclideCertificatesGenerator.get_common_name(server_cert) else: return None