mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 01:11:35 +00:00
move create_csr to gui
This commit is contained in:
parent
6527eae32b
commit
e4038dcdba
2 changed files with 15 additions and 10 deletions
|
@ -2742,3 +2742,16 @@ class ElectrumWindow(QMainWindow):
|
|||
text.setText(mpk_text)
|
||||
vbox.addLayout(Buttons(CloseButton(d)))
|
||||
d.exec_()
|
||||
|
||||
@protected
|
||||
def create_csr(self, alias, challenge, password):
|
||||
from electrum import x509
|
||||
import tlslite
|
||||
xprv = self.wallet.get_master_private_key(self.wallet.root_name, password)
|
||||
_, _, _, c, k = bitcoin.deserialize_xkey(xprv)
|
||||
csr = x509.create_csr(alias, challenge, k)
|
||||
csr = tlslite.utils.pem.pem(bytearray(csr), "CERTIFICATE REQUEST")
|
||||
with open('test.csr', 'w') as f:
|
||||
f.write(csr)
|
||||
#os.system('openssl asn1parse -i -in test.csr')
|
||||
return 'test.csr'
|
||||
|
|
12
lib/x509.py
12
lib/x509.py
|
@ -237,11 +237,10 @@ def int_to_bytestr(i):
|
|||
s = chr(i % 256) + s
|
||||
return s
|
||||
|
||||
def create_csr(commonName, challenge, secexp):
|
||||
|
||||
def create_csr(commonName, challenge, k):
|
||||
import ecdsa, hashlib
|
||||
from bitcoin import point_to_ser
|
||||
private_key = ecdsa.SigningKey.from_secret_exponent(secexp, curve = ecdsa.SECP256k1)
|
||||
private_key = ecdsa.SigningKey.from_string(k, curve = ecdsa.SECP256k1)
|
||||
public_key = private_key.get_verifying_key()
|
||||
pubkey = point_to_ser(public_key.pubkey.point, False)
|
||||
asn1_type_table = {
|
||||
|
@ -295,10 +294,3 @@ def create_csr(commonName, challenge, secexp):
|
|||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import os
|
||||
csr = create_csr('test@electrum.org', 'blah', 123456)
|
||||
with open('test.csr', 'w') as f:
|
||||
o = tlslite.utils.pem.pem(bytearray(csr), "CERTIFICATE REQUEST")
|
||||
f.write(o)
|
||||
os.system('openssl asn1parse -i -in test.csr')
|
||||
|
|
Loading…
Add table
Reference in a new issue