// SetCertificatePem sets the CertificatePem field's value.
962837
func (s *CACertificateDescription) SetCertificatePem(v string) *CACertificateDescription {
	s.CertificatePem = &v
	return s
}
533318
func (s *UploadSigningCertificateOutput) SetCertificate(v *SigningCertificate) *UploadSigningCertificateOutput {
	s.Certificate = v
	return s
}
517
func (s *SslConfiguration) SetCertificate(v string) *SslConfiguration {
	s.Certificate = &v
	return s
}
565150
func (s *CreateEndpointInput) SetCertificateArn(v string) *CreateEndpointInput {
	s.CertificateArn = &v
	return s
}
721353
func (s *ImportCertificateAuthorityCertificateInput) SetCertificate(v []byte) *ImportCertificateAuthorityCertificateInput {
	s.Certificate = v
	return s
}
1149206
func (s *CreateDomainNameInput) SetCertificateName(v string) *CreateDomainNameInput {
	s.CertificateName = &v
	return s
}
464780
func (s *DomainName) SetCertificateName(v string) *DomainName {
	s.CertificateName = &v
	return s
}
131576
func (s *CACertificate) SetCertificateId(v string) *CACertificate {
	s.CertificateId = &v
	return s
}
630213
func (s *CreateLoadBalancerTlsCertificateInput) SetCertificateName(v string) *CreateLoadBalancerTlsCertificateInput {
	s.CertificateName = &v
	return s
}
839700
func (s *RegisterCertificateOutput) SetCertificateId(v string) *RegisterCertificateOutput {
	s.CertificateId = &v
	return s
}
909431
func ParseCertificatePEM(bytes []byte) (*x509.Certificate, error) {
	block, _ := pem.Decode(bytes)
	if block == nil {
		return nil, trace.BadParameter("expected PEM-encoded block")
	}
	cert, err := x509.ParseCertificate(block.Bytes)
	if err != nil {
		return nil, trace.BadParameter(err.Error())
	}
	return cert, nil
}
623634
func (s *Certificate) SetCertificateArn(v string) *Certificate {
	s.CertificateArn = &v
	return s
}
111249
func (d *Data) setCertificateType() error {
	// We want to be able to detect 'false' CA certificates, classify as CA
	// certificate is basic contains and key usage certsign are set.
	if d.Cert.IsCA && d.Cert.KeyUsage&x509.KeyUsageCertSign != 0 {
		d.Type = "CA"
		return nil
	}

	// The fallback type is used when a certificate could be any of a range
	// but further checks need to define the exact type. When these checks fail
	// the fallback type is used.
	var fallbackType string

	// Based on ExtKeyUsage
	for _, ku := range d.Cert.ExtKeyUsage {
		switch ku {
		case x509.ExtKeyUsageServerAuth:
			// Try to determine certificate type via policy oid
			d.Type = getType(d.Cert.PolicyIdentifiers)
			fallbackType = "DV"
		case x509.ExtKeyUsageClientAuth:
			fallbackType = "PS"
		case x509.ExtKeyUsageEmailProtection:
			d.Type = "PS"
		case x509.ExtKeyUsageCodeSigning:
			d.Type = "CS"
		case x509.ExtKeyUsageTimeStamping:
			d.Type = "TS"
		case x509.ExtKeyUsageOCSPSigning:
			d.Type = "OCSP"
		}
	}

	// If we have no known key usage, try the policy list again
	if d.Type == "" {
		d.Type = getType(d.Cert.PolicyIdentifiers)
	}

	// When determined by Policy Identifier we can stop
	if d.Type != "" {
		return nil
	}

	// Based on UnknownExtKeyUsage
	for _, ku := range d.Cert.UnknownExtKeyUsage {
		switch {
		case ku.Equal(asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 311, 21, 19}):
			// dsEmailReplication
			d.Type = "PS"
			return nil
		case ku.Equal(asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 8, 2, 2}):
			// IPSEC Protection
			d.Type = "IPSEC"
			return nil
		}
	}

	// Check if the e-mailAddress is set in the DN
	for _, n := range d.Cert.Subject.Names {
		switch {
		case n.Type.Equal(asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 1}): // e-mailAddress
			d.Type = "PS"
			return nil
		}
	}

	// An @ sing in the common name is often used in PS.
	if strings.Contains(d.Cert.Subject.CommonName, "@") {
		d.Type = "PS"
		return nil
	} else if strings.Contains(d.Cert.Subject.CommonName, " ") {
		d.Type = "PS"
		return nil
	}

	// If it's a fqdn, it's a EV, OV or DV
	if suffix, _ := psl.PublicSuffix(strings.ToLower(d.Cert.Subject.CommonName)); len(suffix) > 0 {
		if len(d.Cert.Subject.Organization) > 0 {
			if len(d.Cert.Subject.SerialNumber) > 0 {
				d.Type = "EV"
				return nil
			}

			d.Type = "OV"
			return nil
		}

		d.Type = "DV"
		return nil
	}

	if len(fallbackType) > 0 {
		d.Type = fallbackType
		return nil
	}

	if d.Type == "" {
		return fmt.Errorf("Could not determine certificate type")
	}
	return nil
}
525998
func (s *CreateDomainNameInput) SetCertificateArn(v string) *CreateDomainNameInput {
	s.CertificateArn = &v
	return s
}
227266
func (s *DescribeCertificateInput) SetCertificateId(v string) *DescribeCertificateInput {
	s.CertificateId = &v
	return s
}
459412
func ParseCertificatePEM(certPEM []byte) (*Certificate, error) {
	cert, err := helpers.ParseCertificatePEM(certPEM)
	if err != nil {
		return nil, err
	}

	return ParseCertificate(cert), nil
}
1299410
func (s *Certificate) SetCertificateId(v string) *Certificate {
	s.CertificateId = &v
	return s
}