Skip to content

Commit

Permalink
Using getpass input for passphrase. It closes #11.
Browse files Browse the repository at this point in the history
Signed-off-by: Pol Henarejos <[email protected]>
  • Loading branch information
polhenarejos committed Oct 29, 2021
1 parent fdb055b commit 242a6af
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions certbot_castle/plugins/installer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import abc
import getpass

import zope.interface

Expand Down Expand Up @@ -53,12 +54,11 @@ def deploy_cert(self, domain, cert_path, key_path, chain_path=None, fullchain_pa
else:
text = 'A passphrase is needed for protecting the PKCS12 container. '
notify(text,pause=False)
input = zope.component.getUtility(interfaces.IDisplay).input
code,pf = input('Enter passphrase: ', force_interactive=True)
code,vpf = input('Re-enter passphrase: ', force_interactive=True)
pf = getpass.getpass('Enter passphrase: ')
vpf = getpass.getpass('Re-enter passphrase: ')
while (pf != vpf):
notify('Passphrases do not match.',pause=False)
code, vpf = input('Re-enter passphrase: ', force_interactive=True)
vpf = getpass.getpass('Re-enter passphrase: ')
passphrase = pf.encode('utf-8')
algo = serialization.BestAvailableEncryption(passphrase) if passphrase else serialization.NoEncryption()
pfxdata = pkcs12.serialize_key_and_certificates(name=domain.encode('utf-8'), key=privkey, cert=cert, cas=[chain], encryption_algorithm=algo)
Expand Down

0 comments on commit 242a6af

Please sign in to comment.