func NewCertificate(publicKeyPem, privateKeyPem string) (Certificate, error) {
	publicKey, err := jwt.ParseRSAPublicKeyFromPEM([]byte(publicKeyPem))
	if err != nil {
		return nil, fmt.Errorf("error with public key: %w", err)
	}
	publicPem := []byte(publicKeyPem)

	privateKey, err := jwt.ParseRSAPrivateKeyFromPEM([]byte(privateKeyPem))
	if err != nil {
		return nil, fmt.Errorf("error with private key: %w", err)
	}

	tlsCert, err := tls.X509KeyPair([]byte(publicKeyPem), []byte(privateKeyPem))
	if err != nil {
		logrus.StandardLogger().Warnln("tls.X509KeyPair, err=", err)
	}

	if err := validateKeys(publicKey, privateKey); err != nil {
		return nil, err
	}

	return &certificate{
		publicKey:     publicKey,
		privateKey:    privateKey,
		tlsCert:       tlsCert,
		publicCertPem: publicPem,
	}, nil
}
// NewCertificate - create new Certificate.
//
// Parameters:
// * publicKeyPem=PEM encoded public key.
// * privateKeyPem=PEM encoded private key.
//
// Returns Certificate, or nil with error set if something is invalid.
create new Certificate.

publicKeyPem=PEM encoded public key.
privateKeyPem=PEM encoded private key.

Returns Certificate, or nil with error set if something is invalid.
// NewCertificate - create new Certificate . // // Parameters : // * publicKeyPem = PEM encoded public key . // * privateKeyPem = PEM encoded private key . // // Returns Certificate or nil with error set if something is invalid .
func NewCertificate(publicKeyPem, privateKeyPem string) (Certificate, error) {
	publicKey, err := jwt.ParseRSAPublicKeyFromPEM([]byte(publicKeyPem))
	if err != nil {
		return nil, fmt.Errorf("error with public key: %w", err)
	}
	publicPem := []byte(publicKeyPem)
	privateKey, err := jwt.ParseRSAPrivateKeyFromPEM([]byte(privateKeyPem))
	if err != nil {
		return nil, fmt.Errorf("error with private key: %w", err)
	}
	tlsCert, err := tls.X509KeyPair([]byte(publicKeyPem), []byte(privateKeyPem))
	if err != nil {
		logrus.StandardLogger().Warnln("tls.X509KeyPair, err=", err)
	}
	if err := validateKeys(publicKey, privateKey); err != nil {
		return nil, err
	}
	return &certificate{
		publicKey:     publicKey,
		privateKey:    privateKey,
		tlsCert:       tlsCert,
		publicCertPem: publicPem,
	}, nil
}
func NewCertificate ( publicKeyPem , privateKeyPem string ) ( Certificate , error ) { publicKey , err := jwt . ParseRSAPublicKeyFromPEM ( [ ] byte ( publicKeyPem ) ) if err != nil { return nil , fmt . Errorf ( " " , err ) } publicPem := [ ] byte ( publicKeyPem ) privateKey , err := jwt . ParseRSAPrivateKeyFromPEM ( [ ] byte ( privateKeyPem ) ) if err != nil { return nil , fmt . Errorf ( " " , err ) } tlsCert , err := tls . X509KeyPair ( [ ] byte ( publicKeyPem ) , [ ] byte ( privateKeyPem ) ) if err != nil { logrus . StandardLogger ( ) . Warnln ( " " , err ) } if err := validateKeys ( publicKey , privateKey ) ; err != nil { return nil , err } return & certificate { publicKey : publicKey , privateKey : privateKey , tlsCert : tlsCert , publicCertPem : publicPem , } , nil }
create new Certificate.
create new Certificate .