we want to allow self-signed certificates.
344686
private static TrustManager[] getNonValidatingTrustManagers(String[] acceptedIssuers) {
        X509TrustManager x509TrustManager = new CustomX509TrustManager(acceptedIssuers);
        return new TrustManager[]{x509TrustManager};
    }
809355
def generateCertificate(cls):
        
        key = generate_key()
        cert = generate_certificate(key)
        return cls(key=key, cert=cert)
252215
public void saveCertificateChain(OutputStream out) throws IOException, CertificateEncodingException {

        CertificateIOUtil.writeCertificate(out, this.certChain[0]);

        for (int i = 1; i < this.certChain.length; i++) {
            // skip the self-signed certificates
            if (this.certChain[i].getSubjectDN().equals(certChain[i].getIssuerDN())) {
                continue;
            }
            CertificateIOUtil.writeCertificate(out, this.certChain[i]);
        }
        out.flush();
    }
985006
def _makeCertificate(key, email, _utcnow=datetime.utcnow):
    
    # Create a certificate for this key.
    cert = X509()
    cert.set_pubkey(key)

    # Set the subject.
    subject = cert.get_subject()
    subject.CN = u"Crypto 101 Client"
    subject.emailAddress = email

    # Expiration dates. Mandatory.
    now = _utcnow()
    start = now.replace(hour=0, minute=0, second=0)
    cert.set_notBefore(start.strftime(_ASN1_GENERALIZEDTIME_FORMAT))
    end = start.replace(year=start.year + 5)
    cert.set_notAfter(end.strftime(_ASN1_GENERALIZEDTIME_FORMAT))

    # Self-sign.
    cert.set_issuer(cert.get_subject())
    cert.sign(key, "sha512")

    return cert
1133578
def setup_signing(self, secret_key, sign_outgoing=True, allow_unsigned_callback=None, initial_timestamp=None, link_id=None):
        ''''''
        self.mav.signing.secret_key = secret_key
        self.mav.signing.sign_outgoing = sign_outgoing
        self.mav.signing.allow_unsigned_callback = allow_unsigned_callback
        if link_id is None:
            # auto-increment the link_id for each link
            global global_link_id
            link_id = global_link_id
            global_link_id = min(global_link_id + 1, 255)
        self.mav.signing.link_id = link_id
        if initial_timestamp is None:
            # timestamp is time since 1/1/2015
            epoch_offset = 1420070400
            now = max(time.time(), epoch_offset)
            initial_timestamp = now - epoch_offset
            initial_timestamp = int(initial_timestamp * 100 * 1000)
        # initial_timestamp is in 10usec units
        self.mav.signing.timestamp = initial_timestamp
522053
private boolean requireSigningPolicyCheck(GSIConstants.CertificateType certType) {

        return !ProxyCertificateUtil.isProxy(certType) && certType != GSIConstants.CertificateType.CA;
    }
854969
private function createKeys()
    {
        //Create Can Keys
        shuffle(Devbr\Can::$base);
        shuffle(Devbr\Can::$extra_base);
        file_put_contents($this->configKeyPath.'can.key', implode(Devbr\Can::$base)."\n".implode(Devbr\Can::$extra_base));

        $SSLcnf = [];
        $dn = [];

        //get configurations
        include $this->configKeyPath.'openssl.config.php';

        // Generate a new private (and public) key pair
        $privkey = openssl_pkey_new($SSLcnf);

        // Generate a certificate signing request
        $csr = openssl_csr_new($dn, $privkey, $SSLcnf);

        // You will usually want to create a self-signed certificate at this
        // point until your CA fulfills your request.
        // This creates a self-signed cert that is valid for 365 days
        $sscert = openssl_csr_sign($csr, null, $privkey, 365, $SSLcnf);

        //CERTIFICADO
        openssl_csr_export_to_file($csr, $this->configKeyPath.'certificate.crt', false);

        //CERTIFICADO AUTO-ASSINADO
        openssl_x509_export_to_file($sscert, $this->configKeyPath.'self_signed_certificate.cer', false);

        //CHAVE PRIVADA (private.pem)
        openssl_pkey_export_to_file($privkey, $this->configKeyPath.'private.key', null, $SSLcnf);

        //CHAVE PÚBLICA (public.key)
        file_put_contents($this->configKeyPath.'public.key', openssl_pkey_get_details($privkey)['key']);
    }
1068205
def self_signed(self, value):
        

        self._self_signed = bool(value)

        if self._self_signed:
            self._issuer = None
1154099
def new_credentials(cls):
        """"""
        from cryptography import x509
        from cryptography.hazmat.backends import default_backend
        from cryptography.hazmat.primitives import hashes
        from cryptography.hazmat.primitives import serialization
        from cryptography.hazmat.primitives.asymmetric import rsa
        from cryptography.x509.oid import NameOID

        key = rsa.generate_private_key(public_exponent=65537,
                                       key_size=2048,
                                       backend=default_backend())
        key_bytes = key.private_bytes(
            encoding=serialization.Encoding.PEM,
            format=serialization.PrivateFormat.PKCS8,
            encryption_algorithm=serialization.NoEncryption())

        subject = issuer = x509.Name(
            [x509.NameAttribute(NameOID.COMMON_NAME, u'skein-internal')])
        now = datetime.utcnow()
        cert = (x509.CertificateBuilder()
                    .subject_name(subject)
                    .issuer_name(issuer)
                    .public_key(key.public_key())
                    .serial_number(x509.random_serial_number())
                    .not_valid_before(now)
                    .not_valid_after(now + timedelta(days=365))
                    .sign(key, hashes.SHA256(), default_backend()))

        cert_bytes = cert.public_bytes(serialization.Encoding.PEM)

        return cls(cert_bytes=cert_bytes, key_bytes=key_bytes)
257426
def certificate(self, value):
        """"""
        import os
        if os.path.isfile(value):
            self._certificatefile = value
633778
def enable_usage_rights(cert, pkey, *rights)

            # Always uses a detached PKCS7 signature for UR.
            method = Signature::PKCS7_DETACHED

            #
            # Load key pair
            #
            key = pkey.is_a?(OpenSSL::PKey::RSA) ? pkey : OpenSSL::PKey::RSA.new(pkey)
            certificate = cert.is_a?(OpenSSL::X509::Certificate) ? cert : OpenSSL::X509::Certificate.new(cert)

            #
            # Forge digital signature dictionary
            #
            digsig = Signature::DigitalSignature.new.set_indirect(true)

            self.Catalog.AcroForm ||= InteractiveForm.new
            #self.Catalog.AcroForm.SigFlags = InteractiveForm::SigFlags::APPEND_ONLY

            digsig.Type = :Sig
            digsig.Contents = HexaString.new("\x00" * Signature.required_size(method, certificate, key, []))
            digsig.Filter = :"Adobe.PPKLite"
            digsig.Name = "ARE Acrobat Product v8.0 P23 0002337"
            digsig.SubFilter = Name.new(method )
            digsig.ByteRange = [0, 0, 0, 0]

            sigref = Signature::Reference.new
            sigref.Type = :SigRef
            sigref.TransformMethod = :UR3
            sigref.Data = self.Catalog

            sigref.TransformParams = UsageRights::TransformParams.new
            sigref.TransformParams.P = true
            sigref.TransformParams.Type = :TransformParams
            sigref.TransformParams.V = UsageRights::TransformParams::VERSION

            rights.each do |right|
                sigref.TransformParams[right.first] ||= []
                sigref.TransformParams[right.first].concat(right[1..-1])
            end

            digsig.Reference = [ sigref ]

            self.Catalog.Perms ||= Perms.new
            self.Catalog.Perms.UR3 = digsig

            #
            #  Flattening the PDF to get file view.
            #
            compile

            #
            # Creating an empty Xref table to compute signature byte range.
            #
            rebuild_dummy_xrefs

            sig_offset = get_object_offset(digsig.no, digsig.generation) + digsig.signature_offset

            digsig.ByteRange[0] = 0
            digsig.ByteRange[1] = sig_offset
            digsig.ByteRange[2] = sig_offset + digsig.Contents.size

            until digsig.ByteRange[3] == filesize - digsig.ByteRange[2]
                digsig.ByteRange[3] = filesize - digsig.ByteRange[2]
            end

            # From that point on, the file size remains constant

            #
            # Correct Xrefs variations caused by ByteRange modifications.
            #
            rebuild_xrefs

            file_data = output()
            signable_data = file_data[digsig.ByteRange[0],digsig.ByteRange[1]] +
                file_data[digsig.ByteRange[2],digsig.ByteRange[3]]

            signature = Signature.compute(method, signable_data, certificate, key, [])
            digsig.Contents[0, signature.size] = signature

            #
            # No more modification are allowed after signing.
            #
            self.freeze
        end
428282
private function prepare_signing_key() {
    $left = $this->safe_encode($this->config['consumer_secret']);
    $right = $this->safe_encode($this->secret());
    $this->request_settings['signing_key'] = $left . '&' . $right;
  }
291334
def setCredentials(self, creds):
        """"""

        if isinstance(creds, UserKeyCredential):
            self.setUserKeyCredentials(creds.username, creds.public_key, creds.private_key)
        elif isinstance(creds, UserPassCredential):
            self.setUserPasswdCredentials(creds.username, creds.password)
1288292
private function configureSslValidation()
    {
        // set SSL validation for the CAS server
        if ($this->config['cas_validation'] == 'ca' || $this->config['cas_validation'] == 'self')
        {
            phpCAS::setCasServerCACert($this->config['cas_cert']);
        }
        else
        {
            phpCAS::setNoCasServerValidation();
        }
    }
380351
def sign(self, identity, blob):
        """"""
        if identity.identity_dict['proto'] in {'ssh'}:
            digest = hashlib.sha256(blob).digest()
        else:
            digest = blob
        return self.sk.sign_digest_deterministic(digest=digest,
                                                 hashfunc=hashlib.sha256)
1051968
def add_certificate(certfile, attributes, viewable: false, editable: false)
            if certfile.is_a?(OpenSSL::X509::Certificate)
                x509 = certfile
            else
                x509 = OpenSSL::X509::Certificate.new(certfile)
            end

            address_book = get_address_book

            cert = Certificate.new
            cert.Cert = x509.to_der
            cert.ID = address_book.NextID
            address_book.NextID += 1

            cert.Trust = attributes
            cert.Viewable = viewable
            cert.Editable = editable

            address_book.Entries.push(self << cert)
        end
234616
function proprietaryCertificate() {
	var self = {
		__TYPE__ : CertificateType.CERT_CHAIN_VERSION_1,
		dwSigAlgId : new type.UInt32Le(0x00000001, { constant : true }),
        dwKeyAlgId : new type.UInt32Le(0x00000001, { constant : true }),
        wPublicKeyBlobType : new type.UInt16Le(0x0006, { constant : true }),
        wPublicKeyBlobLen : new type.UInt16Le(function() {
        	return self.PublicKeyBlob.size();
        }),
        PublicKeyBlob : rsaPublicKey({ readLength : new type.CallableValue(function() {
        	return self.wPublicKeyBlobLen.value;
        }) }),
        wSignatureBlobType : new type.UInt16Le(0x0008, { constant : true }),
        wSignatureBlobLen : new type.UInt16Le(function() {
        	return self.SignatureBlob.size() + self.padding.size();
        }),
        SignatureBlob : new type.BinaryString(null, { readLength : new type.CallableValue(function() {
        	return self.wSignatureBlobLen.value - self.padding.size;
        }) }),
        padding : new type.BinaryString(Array(8 + 1).join('\x00'), { readLength : new type.CallableValue(8) }),
        /**
         * @return {object} rsa.publicKey
         */
        getPublicKey : function() {
        	return rsa.publicKey(self.PublicKeyBlob.obj.modulus.value, self.PublicKeyBlob.obj.pubExp.value);
        }
	};
	
	return new type.Component(self);
}