# Path: pki/settings.py
# PKI_DIR = getattr(settings, 'PKI_DIR', os.path.join(PKI_APP_DIR, 'PKI'))
# 
# PKI_CA_NAME_BLACKLIST = ('_SELF_SIGNED_CERTIFICATES',)
# 
# Path: pki/openssl.py
# def refresh_pki_metadata(ca_list):
#     def __init__(self, instance):
#     def exec_openssl(self, command, env_vars=None):
#     def generate_key(self):
#     def generate_self_signed_cert(self):
#     def generate_csr(self):
#     def generate_der_encoded(self):
#     def remove_der_encoded(self):
#     def generate_pkcs12_encoded(self):
#     def remove_pkcs12_encoded(self):
#     def remove_complete_certificate(self):
#     def sign_csr(self):
#     def revoke_certificate(self, ppf):
#     def generate_crl(self, ca=None, pf=None):
#     def update_ca_chain_file(self):
#     def get_serial_from_cert(self):
#     def get_hash_from_cert(self):
#     def get_revoke_status_from_cert(self):
#     def dump_certificate(self):
#     def rollback(self):
# class Openssl():


import os
from django import forms
from django.forms.util import ErrorList
from django.shortcuts import get_object_or_404
from pki.models import *
from pki.settings import PKI_DIR, PKI_CA_NAME_BLACKLIST
from pki.openssl import md5_constructor
    
    class Meta:
        model = CertificateAuthority
    
    def clean(self):
        """Verify fields"""
        
        cleaned_data = self.cleaned_data
        
        name = cleaned_data.get('name')
        action = cleaned_data.get('action')
        parent = cleaned_data.get('parent')
        pf = cleaned_data.get('passphrase')
        pf_v = cleaned_data.get('passphrase_verify')
        p_pf = cleaned_data.get('parent_passphrase')
        extension = cleaned_data.get('extension')
        crl_dpoints = cleaned_data.get('crl_dpoints')
        
        enc_p_pf = None
        
        if name in PKI_CA_NAME_BLACKLIST:
            self._errors['name'] = ErrorList(['Name "%s" is blacklisted!' % name])
            return cleaned_data
        
        if action in ('create', 'renew'):
            if action == 'create':
                if not pf_v or pf != pf_v:
                    self.errors['passphrase_verify'] = ErrorList(['Passphrase mismtach!'])
                
                ## Verify that we're not creating a certificate that already exists

# Path: pki/settings.py
# PKI_DIR = getattr(settings, 'PKI_DIR', os.path.join(PKI_APP_DIR, 'PKI'))
# 
# PKI_CA_NAME_BLACKLIST = ('_SELF_SIGNED_CERTIFICATES',)
# 
# Path: pki/openssl.py
# def refresh_pki_metadata(ca_list):
#     def __init__(self, instance):
#     def exec_openssl(self, command, env_vars=None):
#     def generate_key(self):
#     def generate_self_signed_cert(self):
#     def generate_csr(self):
#     def generate_der_encoded(self):
#     def remove_der_encoded(self):
#     def generate_pkcs12_encoded(self):
#     def remove_pkcs12_encoded(self):
#     def remove_complete_certificate(self):
#     def sign_csr(self):
#     def revoke_certificate(self, ppf):
#     def generate_crl(self, ca=None, pf=None):
#     def update_ca_chain_file(self):
#     def get_serial_from_cert(self):
#     def get_hash_from_cert(self):
#     def get_revoke_status_from_cert(self):
#     def dump_certificate(self):
#     def rollback(self):
# class Openssl():


# Path: pki/forms.py
import os
from django import forms
from django.forms.util import ErrorList
from django.shortcuts import get_object_or_404
from pki.models import *
from pki.settings import PKI_DIR, PKI_CA_NAME_BLACKLIST
from pki.openssl import md5_constructor

    
    class Meta:
        model = CertificateAuthority
    
    def clean(self):
        """Verify fields"""
        
        cleaned_data = self.cleaned_data
        
        name = cleaned_data.get('name')
        action = cleaned_data.get('action')
        parent = cleaned_data.get('parent')
        pf = cleaned_data.get('passphrase')
        pf_v = cleaned_data.get('passphrase_verify')
        p_pf = cleaned_data.get('parent_passphrase')
        extension = cleaned_data.get('extension')
        crl_dpoints = cleaned_data.get('crl_dpoints')
        
        enc_p_pf = None
        
        if name in PKI_CA_NAME_BLACKLIST:
            self._errors['name'] = ErrorList(['Name "%s" is blacklisted!' % name])
            return cleaned_data
        
        if action in ('create', 'renew'):
            if action == 'create':
                if not pf_v or pf != pf_v:
                    self.errors['passphrase_verify'] = ErrorList(['Passphrase mismtach!'])
                
                ## Verify that we're not creating a certificate that already exists

                if name and os.path.isdir(os.path.join(PKI_DIR, name)):