func newCertificateSecret(cr *v1alpha1.RethinkDBCluster, name string, caCert *x509.Certificate, caKey *rsa.PrivateKey) (*corev1.Secret, error) {
	secret := newTLSSecret(cr, name)

	key, err := newPrivateKey()
	if err != nil {
		return nil, err
	}

	cfg := &tlsutil.CertConfig{
		CertName:     name,
		CertType:     tlsutil.ClientAndServingCert,
		CommonName:   name,
		Organization: []string{cr.ObjectMeta.Namespace},
	}

	dnsNames := []string{
		cr.ObjectMeta.Name,
		fmt.Sprintf("%s.%s.svc.cluster.local", cr.ObjectMeta.Name, cr.ObjectMeta.Namespace),
	}

	cert, err := newSignedCertificate(cfg, dnsNames, key, caCert, caKey)
	if err != nil {
		return nil, err
	}

	secret.Data = map[string][]byte{
		corev1.TLSCertKey:       encodeCertificatePEM(cert),
		corev1.TLSPrivateKeyKey: encodePrivateKeyPEM(key),
	}

	return secret, nil
}
// newCertificateSecret creates a new secret for a TLS certificate.
newCertificateSecret creates a new secret for a TLS certificate.
// newCertificateSecret creates a new secret for a TLS certificate .
func newCertificateSecret(cr *v1alpha1.RethinkDBCluster, name string, caCert *x509.Certificate, caKey *rsa.PrivateKey) (*corev1.Secret, error) {
	secret := newTLSSecret(cr, name)
	key, err := newPrivateKey()
	if err != nil {
		return nil, err
	}
	cfg := &tlsutil.CertConfig{
		CertName:     name,
		CertType:     tlsutil.ClientAndServingCert,
		CommonName:   name,
		Organization: []string{cr.ObjectMeta.Namespace},
	}
	dnsNames := []string{
		cr.ObjectMeta.Name,
		fmt.Sprintf("%s.%s.svc.cluster.local", cr.ObjectMeta.Name, cr.ObjectMeta.Namespace),
	}
	cert, err := newSignedCertificate(cfg, dnsNames, key, caCert, caKey)
	if err != nil {
		return nil, err
	}
	secret.Data = map[string][]byte{
		corev1.TLSCertKey:       encodeCertificatePEM(cert),
		corev1.TLSPrivateKeyKey: encodePrivateKeyPEM(key),
	}
	return secret, nil
}
func newCertificateSecret ( cr * v1alpha1 . RethinkDBCluster , name string , caCert * x509 . Certificate , caKey * rsa . PrivateKey ) ( * corev1 . Secret , error ) { secret := newTLSSecret ( cr , name ) key , err := newPrivateKey ( ) if err != nil { return nil , err } cfg := & tlsutil . CertConfig { CertName : name , CertType : tlsutil . ClientAndServingCert , CommonName : name , Organization : [ ] string { cr . ObjectMeta . Namespace } , } dnsNames := [ ] string { cr . ObjectMeta . Name , fmt . Sprintf ( " " , cr . ObjectMeta . Name , cr . ObjectMeta . Namespace ) , } cert , err := newSignedCertificate ( cfg , dnsNames , key , caCert , caKey ) if err != nil { return nil , err } secret . Data = map [ string ] [ ] byte { corev1 . TLSCertKey : encodeCertificatePEM ( cert ) , corev1 . TLSPrivateKeyKey : encodePrivateKeyPEM ( key ) , } return secret , nil }
newCertificateSecret creates a new secret for a TLS certificate.
newCertificateSecret creates a new secret for a TLS certificate .