Add a new crt in the hosted cert store.
186489
def create(cls, key, crt):
        
        options = {'crt': crt, 'key': key}
        return cls.call('cert.hosted.create', options)
621627
def add_record(self, common_name, serial=0, parent_ca='',
                   signees=None, files=None, record=None,
                   is_ca=False, overwrite=False):
        

        if not overwrite:
            try:
                self.get_record(common_name)
                raise CertExistsError(
                    "Certificate {name} already exists!"
                    " Set overwrite=True to force add."
                    .format(name=common_name))
            except CertNotFoundError:
                pass

        record = record or {
            'serial': serial,
            'is_ca': is_ca,
            'parent_ca': parent_ca,
            'signees': signees,
            'files': files,
        }
        self.store[common_name] = record
        self.save()
481231
def importExistingServerCertificate(self, alias, certPassword, certFile):
        """"""
        url = self._url + "/sslcertificates/importExistingServerCertificate"
        files = {}
        files['certFile'] = certFile
        params = {
            "f" : "json",
            "alias" : alias,
            "certPassword" : certPassword
        }
        return self._post(url=url,
                            param_dict=params,
                            securityHandler=self._securityHandler,
                            files=files,
                            proxy_url=self._proxy_url,
                            proxy_port=self._proxy_port)
259383
protected function addStore()
    {
        $this->controlAccess('store_add');

        if ($this->store->add($this->getSubmitted())) {
            $this->redirect('admin/settings/store', $this->text('Store has been added'), 'success');
        }

        $this->redirect('', $this->text('Store has not been added'), 'warning');
    }
563231
def LoadServerCertificate(self, server_certificate=None, ca_certificate=None):
    """"""
    # Check that the server certificate verifies
    try:
      server_certificate.Verify(ca_certificate.GetPublicKey())
    except rdf_crypto.VerificationError as e:
      self.server_name = None
      raise IOError("Server cert is invalid: %s" % e)

    # Make sure that the serial number is higher.
    server_cert_serial = server_certificate.GetSerialNumber()

    if server_cert_serial < config.CONFIG["Client.server_serial_number"]:
      # We can not accept this serial number...
      raise IOError("Server certificate serial number is too old.")
    elif server_cert_serial > config.CONFIG["Client.server_serial_number"]:
      logging.info("Server serial number updated to %s", server_cert_serial)
      config.CONFIG.Set("Client.server_serial_number", server_cert_serial)

      # Save the new data to the config file.
      config.CONFIG.Write()

    self.server_name = server_certificate.GetCN()
    self.server_certificate = server_certificate
    self.ca_certificate = ca_certificate
    self.server_public_key = server_certificate.GetPublicKey()
    # If we still have a cached session key, we need to remove it.
    self._ClearServerCipherCache()
480722
def addPrivateCertificate(self, subjectName, existingCertificate=None):
        
        if existingCertificate is None:
            assert '@' not in subjectName, "Don't self-sign user certs!"
            mainDN = DistinguishedName(commonName=subjectName)
            mainKey = KeyPair.generate()
            mainCertReq = mainKey.certificateRequest(mainDN)
            mainCertData = mainKey.signCertificateRequest(
                mainDN, mainCertReq,
                lambda dn: True,
                self.genSerial(subjectName)
            )
            mainCert = mainKey.newCertificate(mainCertData)
        else:
            mainCert = existingCertificate
        self.localStore[subjectName] = mainCert
789126
public function newPreset() {
		$name = esc_html($_POST['name']);
		if(empty($name)) {
			json_response([
				              'status' => 'error',
				              'error' => 'Seems that you may have forgotten something.'
			              ]);
		}

		$key = sanitize_title($name);
		$newKey = $key;

		$presets = get_option('ilab-imgix-presets');
		if($presets) {
			$keyIndex = 1;
			while(isset($presets[$newKey])) {
				$keyIndex ++;
				$newKey = $key.$keyIndex;
			}
		}

		$settings = $_POST['settings'];
		$size = (isset($_POST['size'])) ? esc_html($_POST['size']) : null;
		$makeDefault = (isset($_POST['make_default'])) ? ($_POST['make_default'] == 1) : false;

		$this->doUpdatePresets($newKey, $name, $settings, $size, $makeDefault);

	}
1115432
def update(gandi, resource, ssl, private_key, poll_cert):
    
    gandi.hostedcert.activate_ssl(resource, ssl, private_key, poll_cert)
451352
def set_creds(self, newCreds):
        """"""
        self.creds = newCreds
        self.on_creds_changed(newCreds)
        return self
168119
def add_device_override(self, addr, cat, subcat, firmware=None):
        """"""
        self.plm.devices.add_override(addr, 'cat', cat)
        self.plm.devices.add_override(addr, 'subcat', subcat)
        if firmware:
            self.plm.devices.add_override(addr, 'firmware', firmware)
446642
def _newConsole(cls, console):
        """"""
        self = cls.__new__(cls)
        _BaseConsole.__init__(self)
        self.console_c = console
        self.console = self
        self.width = _lib.TCOD_console_get_width(console)
        self.height = _lib.TCOD_console_get_height(console)
        return self
77077
def add(self):
        """"""

        yield self.client.create(self.path)
        yield self.client.create(self.path + "/type", self.name)
        yield self.client.create(self.path + "/state")
        yield self.client.create(self.path + "/machines", "[]")

        log.debug("registered service '%s' at %s." % (self.name, self.path))
447459
def vserver_sslcert_add(v_name, sc_name, **connection_args):
    '''
    
    '''
    ret = True
    if vserver_sslcert_exists(v_name, sc_name, **connection_args):
        return False
    nitro = _connect(**connection_args)
    if nitro is None:
        return False
    sslcert = NSSSLVServerSSLCertKeyBinding()
    sslcert.set_vservername(v_name)
    sslcert.set_certkeyname(sc_name)
    try:
        NSSSLVServerSSLCertKeyBinding.add(nitro, sslcert)
    except NSNitroError as error:
        log.debug('netscaler module error - NSSSLVServerSSLCertKeyBinding.add() failed: %s', error)
        ret = False
    _disconnect(nitro)
    return ret
1266648
public static CertStore createCertStore(TrustedCertificates tc) throws Exception {

        CertStore store = null;
        if (tc == null) {
            String caCertPattern = "file:" + CoGProperties.getDefault().getCaCertLocations() + "/*.0";
            store = Stores.getCACertStore(caCertPattern);
        } else {
            SimpleMemoryCertStoreParams params = new SimpleMemoryCertStoreParams(tc.getCertificates(), null);
            params.setCerts(tc.getCertificates());
            store = CertStore.getInstance(SimpleMemoryProvider.CERTSTORE_TYPE, params, SimpleMemoryProvider.PROVIDER_NAME);
        }
        return store;
    }
1198631
@Override
    public void addCircuit(int cic, int dpc) {
        cicMap.put(getChannelID(cic, dpc), dpc);
    }
764155
def install_cert(selfsigned):
    """"""

    _check_root()

    if selfsigned:
        log('Generating self signed (insecure) certificate/key '
            'combination')

        try:
            os.mkdir('/etc/ssl/certs/hfos')
        except FileExistsError:
            pass
        except PermissionError:
            log("Need root (e.g. via sudo) to generate ssl certificate")
            sys.exit(1)

        def create_self_signed_cert():
            """Create a simple self signed SSL certificate"""

            # create a key pair
            k = crypto.PKey()
            k.generate_key(crypto.TYPE_RSA, 1024)

            if os.path.exists(cert_file):
                try:
                    certificate = open(cert_file, "rb").read()
                    old_cert = crypto.load_certificate(crypto.FILETYPE_PEM,
                                                       certificate)
                    serial = old_cert.get_serial_number() + 1
                except (crypto.Error, OSError) as e:
                    log('Could not read old certificate to increment '
                        'serial:', type(e), e, exc=True, lvl=warn)
                    serial = 1
            else:
                serial = 1

            # create a self-signed certificate
            certificate = crypto.X509()
            certificate.get_subject().C = "DE"
            certificate.get_subject().ST = "Berlin"
            certificate.get_subject().L = "Berlin"
            # noinspection PyPep8
            certificate.get_subject().O = "Hackerfleet"
            certificate.get_subject().OU = "Hackerfleet"
            certificate.get_subject().CN = gethostname()
            certificate.set_serial_number(serial)
            certificate.gmtime_adj_notBefore(0)
            certificate.gmtime_adj_notAfter(10 * 365 * 24 * 60 * 60)
            certificate.set_issuer(certificate.get_subject())
            certificate.set_pubkey(k)
            certificate.sign(k, b'sha512')

            open(key_file, "wt").write(str(
                crypto.dump_privatekey(crypto.FILETYPE_PEM, k),
                encoding="ASCII"))

            open(cert_file, "wt").write(str(
                crypto.dump_certificate(crypto.FILETYPE_PEM, certificate),
                encoding="ASCII"))

            open(combined_file, "wt").write(str(
                crypto.dump_certificate(crypto.FILETYPE_PEM, certificate),
                encoding="ASCII") + str(
                crypto.dump_privatekey(crypto.FILETYPE_PEM, k),
                encoding="ASCII"))

        create_self_signed_cert()

        log('Done: Install Cert')
    else:

        # TODO

        log('Not implemented yet. You can build your own certificate and '
            'store it in /etc/ssl/certs/hfos/server-cert.pem - it should '
            'be a certificate with key, as this is used server side and '
            'there is no way to enter a separate key.', lvl=error)
1370806
def validate(cert, ca_name, crl_file):
    '''
    
    '''
    store = OpenSSL.crypto.X509Store()
    cert_obj = _read_cert(cert)
    if cert_obj is None:
        raise CommandExecutionError(
            'Failed to read cert from {0}, see log for details'.format(cert)
        )
    ca_dir = '{0}/{1}'.format(cert_base_path(), ca_name)
    ca_cert = _read_cert('{0}/{1}_ca_cert.crt'.format(ca_dir, ca_name))
    store.add_cert(ca_cert)
    # These flags tell OpenSSL to check the leaf as well as the
    # entire cert chain.
    X509StoreFlags = OpenSSL.crypto.X509StoreFlags
    store.set_flags(X509StoreFlags.CRL_CHECK | X509StoreFlags.CRL_CHECK_ALL)
    if crl_file is None:
        crl = OpenSSL.crypto.CRL()
    else:
        with salt.utils.files.fopen(crl_file) as fhr:
            crl = OpenSSL.crypto.load_crl(OpenSSL.crypto.FILETYPE_PEM, fhr.read())
    store.add_crl(crl)
    context = OpenSSL.crypto.X509StoreContext(store, cert_obj)
    ret = {}
    try:
        context.verify_certificate()
        ret['valid'] = True
    except OpenSSL.crypto.X509StoreContextError as e:
        ret['error'] = str(e)
        ret['error_cert'] = e.certificate
        ret['valid'] = False
    return ret