Browse Source

fix pub and cert path

master
Andrea Cimbalo 7 years ago
parent
commit
682611f623
5 changed files with 14 additions and 9 deletions
  1. +2
    -1
      models/authority.py
  2. +4
    -4
      models/certificate.py
  3. +5
    -1
      models/request.py
  4. +2
    -2
      models/ssh.py
  5. +1
    -1
      models/ssl.py

+ 2
- 1
models/authority.py View File

@ -59,7 +59,7 @@ class Authority(customModel.CustomModel):
# write the key data from the request into
# the output folder
with open(request.destination + '.pub', 'w') as stream:
with open(request.destination, 'w') as stream:
stream.write(request.key_data)
cert = Certificate(
@ -68,6 +68,7 @@ class Authority(customModel.CustomModel):
date_issued = datetime.now(),
receiver = request.receiver,
serial_number = self.serial,
path = request.cert_destination,
)
cert.validity_interval = self.generate_certificate(request)


+ 4
- 4
models/certificate.py View File

@ -41,12 +41,12 @@ class Certificate(customModel.CustomModel):
help_text = 'how long will the certificate be valid',
)
path = CharField(
help_text = 'certificate\'s path on filesystem',
)
def __repr__(self):
return ( "%s %s for %s on %s issued by %s"%(self.__class__.__name__, self.cert_id, self.receiver, self.date_issued, self.authority))
def __bool__(self):
return os.path.exists(self.path)
@property
def path(self):
return os.path.join(OUTPUT_PATH, self.cert_id + '-cert.pub')

+ 5
- 1
models/request.py View File

@ -33,7 +33,11 @@ class SignRequest(object):
@property
def destination(self):
return os.path.join(OUTPUT_PATH, self.req_id)
return os.path.join(OUTPUT_PATH, self.req_id + ".pub")
@property
def cert_destination(self):
return os.path.join(OUTPUT_PATH, self.req_id + '-cert.pub')
@property
def fields(self):


+ 2
- 2
models/ssh.py View File

@ -97,9 +97,9 @@ class SSHAuthority(Authority):
Sign a *SSHRequest with this certification authority
"""
pub_key_path = request.destination + '.pub'
pub_key_path = request.destination
ca_private_key = self.path
ca_private_key = request.cert_destination
if type(request) == UserSSHRequest:
login_names = [ request.user_name, ]


+ 1
- 1
models/ssl.py View File

@ -73,7 +73,7 @@ class SSLAuthority(Authority):
Sign a *SSLRequest with this certification authority
"""
pub_key_path = request.destination + '.pub'
pub_key_path = request.destination
cert_path = request.destination + '-cert.pub'
with open(pub_key_path, 'w') as stream:


Loading…
Cancel
Save