@param string $name
@param string $privateKey
@param string $leafCertificate
@param string $certificateChain

@throws HttpException

@return CertificateEntity
344207
public function create($name, $privateKey, $leafCertificate, $certificateChain)
    {
        $data = [
            'name' => $name,
            'private_key' => $privateKey,
            'leaf_certificate' => $leafCertificate,
            'certificate_chain' => $certificateChain,
        ];

        $certificate = $this->adapter->post(sprintf('%s/certificates', $this->endpoint), $data);

        $certificate = json_decode($certificate);

        return new CertificateEntity($certificate->certificate);
    }
1240362
private static function getRequiredAttribute(
            $entity,
            string $name,
            string $method
    ) {
        if (!method_exists($entity, $method)) {
            throw new XmlException(
                    'RSSFeedItem ' . get_class($entity)
                    . ' does not offer a method named "' . $method
                    . '" to return the ' . $name . ', but ' . $name
                    . ' is required.'
            );
        }

        return $entity->$method();
    }
129588
public static function loadFromString(string $content, string $password = NULL): Pkcs12 {
        if(!openssl_pkcs12_read($content, $result, $password)) {
            throw new RuntimeException(OpenSSL::getLastError());
        }

        $pkcs12 = new Pkcs12();

        if(array_key_exists('cert', $result)) {
            $certificate = Certificate::createFromString($result['cert']);
            $pkcs12->setCertificate($certificate);
        }

        if(array_key_exists('pkey', $result)) {
            $privateKey = PrivateKey::loadFromString($result['pkey']);
            $pkcs12->setPrivateKey($privateKey);
        }

        if(array_key_exists('extracerts', $result)) {
            $chain = new Chain($result['extracerts']);
            $pkcs12->setChain($chain);
        }

        return $pkcs12;
    }
42342
public static function create(array $certificateChain, array $customHeaders = []): BunqResponseInt
    {
        $apiClient = new ApiClient(static::getApiContext());
        $responseRaw = $apiClient->post(
            vsprintf(
                self::ENDPOINT_URL_CREATE,
                [static::determineUserId()]
            ),
            [self::FIELD_CERTIFICATE_CHAIN => $certificateChain],
            $customHeaders
        );

        return BunqResponseInt::castFromBunqResponse(
            static::processForId($responseRaw)
        );
    }
23166
public static function make($name, $credentials = [])
    {
        if (!$name && !$credentials) {
            return null;
        }

        try {
            $cacheName = (empty($name)) ? self::CACHE_DEFAULT_TYPE : $name;
            $c         = '\\' . __NAMESPACE__ . '\\' . ucfirst($cacheName);
            // check if the class exists or can be loaded
            if (!class_exists($c, true)) {
                throw new CacheException(_('The Cache is not implemented or not installed:') . $c, self::ERROR_CACHE_MISSING, Error::SEVERITY_CRIT, __FILE__, __LINE__);
            }

            /**
             * @var CacheTrait $cache
             */
            $cache = new $c($credentials);

            if ($cache->isConnected() == false) {
                throw new CacheException(_('The Cache could not establish connection:') . $c, self::ERROR_CACHE_MISSING, Error::SEVERITY_CRIT, __FILE__, __LINE__);
            }

        } catch (CacheException $e) {
            throw $e;
        }

        return $cache;
    }
878802
public function cc($addresses, $name = null) {
        $this->message->setCc($addresses, $name);
        return $this;
    }
437147
@Override
    public final Query createNamedQuery(String name)
    {
        checkClosed();
        checkTransactionNeeded();
        return getPersistenceDelegator().createQuery(name);
    }
74621
@Override
	public Certificate engineGetCertificate(String s) {
		ResourceTrustAnchor trustAnchor = getCertificateEntry(s);
		if (trustAnchor != null) {
			try {
				return trustAnchor.getTrustAnchor().getTrustedCert();
			} catch (ResourceStoreException e) {
				return null;
			}
		}
		return null;
	}
626518
private function addClientNode($name)
    {
        $builder                            = new TreeBuilder();
        $node                               = $builder->root($name);
        $checkIfIsOverwrittenTemplateClient = function ($value) {
            return $value !== 'ScoreYa\Cinderella\SDK\Template\TemplateClient';
        };
        $node
            ->addDefaultsIfNotSet()
            ->children()
                ->scalarNode('class')
                    ->defaultValue('ScoreYa\Cinderella\SDK\Template\TemplateClient')
                    ->validate()
                    ->ifTrue($checkIfIsOverwrittenTemplateClient)
                        ->thenInvalid('Class configuration for template client was overwritten with %s.')
                    ->end()
                ->end()
                ->scalarNode('base_url')
                    ->defaultValue('')
                ->end()

            ->end();

        return $node;
    }
1213631
public function sign($contents, $privateKey)
    {
        $rsa = new RSA();
        $rsa->loadKey($privateKey);

        $rsa->setSignatureMode(RSA::SIGNATURE_PKCS1);

        return $rsa->sign($contents);
    }
546953
public function updateCertificate($name, $certificate, $privateKey, $intermediates)
    {
        $this->notAvailableInVersions(1);

        return $this->send('update_certificate', $name, $certificate, $privateKey, $intermediates);
    }
1266561
public function sign($content, $privateKey)
    {
        try {
            return (new CryptoVirgilSigner($this->hashAlgorithm))->sign($content, $privateKey);
        } catch (Exception $exception) {
            throw new ContentSigningException($exception->getMessage(), $exception->getCode());
        }
    }
464139
public static function string(string $key = null, string $name = null)
    {
        $instance = self::init('string', $key, $name);

        $instance->minLength(0);
        $instance->maxLength(0);

        return $instance;
    }
1115602
public function trustAnchorCertificate(): Certificate
    {
        if (!count($this->_certs)) {
            throw new \LogicException("No certificates.");
        }
        return $this->_certs[count($this->_certs) - 1];
    }
835058
static PemEncoded toPEM(ByteBufAllocator allocator, boolean useDirect,
            X509Certificate... chain) throws CertificateEncodingException {

        if (chain == null || chain.length == 0) {
            throw new IllegalArgumentException("X.509 certificate chain can't be null or empty");
        }

        // We can take a shortcut if there is only one certificate and
        // it already happens to be a PemEncoded instance. This is the
        // ideal case and reason why all this exists. It allows the user
        // to pass pre-encoded bytes straight into OpenSSL without having
        // to do any of the extra work.
        if (chain.length == 1) {
            X509Certificate first = chain[0];
            if (first instanceof PemEncoded) {
                return ((PemEncoded) first).retain();
            }
        }

        boolean success = false;
        ByteBuf pem = null;
        try {
            for (X509Certificate cert : chain) {

                if (cert == null) {
                    throw new IllegalArgumentException("Null element in chain: " + Arrays.toString(chain));
                }

                if (cert instanceof PemEncoded) {
                    pem = append(allocator, useDirect, (PemEncoded) cert, chain.length, pem);
                } else {
                    pem = append(allocator, useDirect, cert, chain.length, pem);
                }
            }

            PemValue value = new PemValue(pem, false);
            success = true;
            return value;
        } finally {
            // Make sure we never leak the PEM's ByteBuf in the event of an Exception
            if (!success && pem != null) {
                pem.release();
            }
        }
    }
600326
public function signedRoute($name, $parameters = [], $expiration = null, $absolute = true)
    {
        $parameters = $this->formatParameters($parameters);

        if ($expiration) {
            $parameters = $parameters + ['expires' => $this->availableAt($expiration)];
        }

        ksort($parameters);

        $key = call_user_func($this->keyResolver);

        return $this->route($name, $parameters + [
            'signature' => hash_hmac('sha256', $this->route($name, $parameters, $absolute), $key),
        ], $absolute);
    }
351351
public static void verifyAndThrow(final String name, final X509Certificate cert) throws CertificateException{
		if (!verify(name, cert)) {
			throw new CertificateException("No name matching " + name + " found");
		}		
	}