You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: certfile.go
    path of file: ./repos/kubeedge/edge/pkg/edgehub/common/certutil
    
    the code of the file until where you have to start completion: package certutil

import (
	"crypto"
	"crypto/x509"
	"encoding/pem"
	"fmt"

	certutil "k8s.io/client-go/util/cert"
	"k8s.io/client-go/util/keyutil"
)

func WriteKeyAndCert(keyFile string, certFile string, key crypto.Signer, cert *x509.Certificate) error {
	err := WriteKey(keyFile, key)
	if err != nil {
		return err
	}
	err = WriteCert(certFile, cert)
	if err != nil {
		return err
	}
	return nil
}

// WriteKey stores the given 
    
func WriteKey(pkiPath string, key crypto.Signer) error {
	if key == nil {
		return fmt.Errorf("private key cannot be nil when writing to file")
	}

	encoded, err := keyutil.MarshalPrivateKeyToPEM(key)
	if err != nil {
		return fmt.Errorf("unable to marshal private key to PEM: %w", err)
	}
	if err := keyutil.WriteKey(pkiPath, encoded); err != nil {
		return fmt.Errorf("unable to write private key to file %s: %w", pkiPath, err)
	}

	return nil
}