def register_cb((signedNonce, nonceid)): agent = CookieAgent(Agent(reactor), self.cookie_jar) dataq = [] dataq.append(signedNonce) dataq.append(self.client_id.encryptData(self.client_id.password)) # Sending the Certificate and the Sub CA to the server if self.pin is None: print "ERROR! Check the pin!" reactor.stop() cert = cc.get_certificate(cc.CERT_LABEL, self.pin) #print type(cert.as_pem()) #print cert.as_pem() if cert is None: print "ERROR! Check the pin" reactor.stop() subca = cc.get_certificate(cc.SUBCA_LABEL, self.pin) #print type(subca.as_pem()) #print subca.as_pem() if subca is None: print "ERROR! Check the pin" reactor.stop() enc_cert = b64encode(cert.as_pem()) #print "cert len: ", len(enc_cert) dataq.append(enc_cert) enc_subca = b64encode(subca.as_pem()) #print "sub ca len: ", len(enc_subca) dataq.append(enc_subca) dataq.append(self.client_id.pub_key.exportKey('PEM')) ext_key = self.client_id.pub_key.exportKey('PEM') if self.pin is None: print "ERROR! Check the pin or the CC" reactor.stop() signed_ext_key = cc.sign(ext_key, cc.KEY_LABEL, self.pin) enc_sek = b64encode(signed_ext_key) #print "encoded ext key: ", enc_sek #print "len encoded: ", len(enc_sek) dataq.append(enc_sek) body = FileProducer2(dataq) headers = http_headers.Headers() #print "Password:"******"LEN:", len(self.client_id.encryptData(self.client_id.password)) d = agent.request( 'PUT', 'http://localhost:8000/pboxes/?method=register' + '&nonceid=' + str(nonceid), headers, body) d.addCallback(procResponse_cb, checkClientReg_cb)
required=True, help="password to access the RSA Key in the system") group = parser.add_mutually_exclusive_group(required=True) group.add_argument('-p', '--pin', help="pin to access the Citizen Card") group.add_argument('-c', '--ccid', help="the CC number, when no CC is given") args = parser.parse_args() pwd = args.pwd pin = args.pin if pin is None: ccid = args.ccid else: cert = cc.get_certificate(cc.CERT_LABEL, pin) if cert is None: sys.exit("WRONG PIN / NO CARD ON SLOT") user_data = cc.get_subjdata_from_cert(cert) if user_data is None: sys.exit("WRONG PIN / NO CARD ON SLOT") ccid = user_data[1] ccid = ccid[2:] #print ccid, pwd, pin # dirname for the .pem files = user ccid if not os.path.exists(ccid): sys.exit('ERROR: Directory %s not found!' % ccid) client = SafeBoxClient()
if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('-pw', '--pwd', required=True, help="password to access the RSA Key in the system") group = parser.add_mutually_exclusive_group(required=True) group.add_argument('-p', '--pin', help="pin to access the Citizen Card") group.add_argument('-c', '--ccid', help="the CC number, when no CC is given") args = parser.parse_args() pwd = args.pwd pin = args.pin if pin is None: ccid = args.ccid else: cert = cc.get_certificate(cc.CERT_LABEL, pin) if cert is None: sys.exit("WRONG PIN / NO CARD ON SLOT") user_data = cc.get_subjdata_from_cert(cert) if user_data is None: sys.exit("WRONG PIN / NO CARD ON SLOT") ccid = user_data[1] ccid = ccid[2:] #print ccid, pwd, pin # dirname for the .pem files = user ccid if not os.path.exists(ccid): sys.exit('ERROR: Directory %s not found!' % ccid) client = SafeBoxClient()