func (le *LetsEncrypt) FinalizeOrder(order *acme.Order, domain string, privCertKey crypto.Signer) (privKey string, certificate string, err error) {
	// Generate a new private key if not supplied
	if privCertKey == nil {
		privCertKey, err = rsa.GenerateKey(rand.Reader, 2048)
		if err != nil {
			return "", "", err
		}
	}

	// Create CSR
	req := &x509.CertificateRequest{
		Subject: pkix.Name{CommonName: domain},
	}
	csr, err := x509.CreateCertificateRequest(rand.Reader, req, privCertKey)
	if err != nil {
		return "", "", err
	}

	// Let LetsEncrypt sign the CSR and return the certificate
	certs, _, err := le.AcmeClient.CreateOrderCert(le.Ctx, order.FinalizeURL, csr, true)
	if err != nil {
		return "", "", err
	}

	// Convert all certificates to PEM format
	for _, cert := range certs {
		c, err := x509.ParseCertificate(cert)
		if err != nil {
			return "", "", err
		}

		var b bytes.Buffer
		err = pem.Encode(&b, &pem.Block{Type: "CERTIFICATE", Bytes: c.Raw})
		if err != nil {
			return "", "", err
		}

		certificate += b.String()
	}

	// Convert private and public key to PEM
	privKey, err = privKeyToPEM(privCertKey)
	if err != nil {
		return "", "", err
	}

	return
}
// FinalizeOrder will ask LetsEncrypt for the actual certificate by issusing a certificate order. Note that this can
// only be done with a valid order. When privCertKey is nil, it will generate a new random RSA 2048 key. When we are
// renewing a certificate you might want to keep the same key (or not).
FinalizeOrder will ask LetsEncrypt for the actual certificate by issusing a certificate order. Note that this can
only be done with a valid order. When privCertKey is nil, it will generate a new random RSA 2048 key. When we are
renewing a certificate you might want to keep the same key (or not).
// FinalizeOrder will ask LetsEncrypt for the actual certificate by issusing a certificate order . Note that this can // only be done with a valid order . When privCertKey is nil it will generate a new random RSA 2048 key . When we are // renewing a certificate you might want to keep the same key ( or not ) .
func (le *LetsEncrypt) FinalizeOrder(order *acme.Order, domain string, privCertKey crypto.Signer) (privKey string, certificate string, err error) {
	if privCertKey == nil {
		privCertKey, err = rsa.GenerateKey(rand.Reader, 2048)
		if err != nil {
			return "", "", err
		}
	}
	req := &x509.CertificateRequest{
		Subject: pkix.Name{CommonName: domain},
	}
	csr, err := x509.CreateCertificateRequest(rand.Reader, req, privCertKey)
	if err != nil {
		return "", "", err
	}
	certs, _, err := le.AcmeClient.CreateOrderCert(le.Ctx, order.FinalizeURL, csr, true)
	if err != nil {
		return "", "", err
	}
	for _, cert := range certs {
		c, err := x509.ParseCertificate(cert)
		if err != nil {
			return "", "", err
		}
		var b bytes.Buffer
		err = pem.Encode(&b, &pem.Block{Type: "CERTIFICATE", Bytes: c.Raw})
		if err != nil {
			return "", "", err
		}
		certificate += b.String()
	}
	privKey, err = privKeyToPEM(privCertKey)
	if err != nil {
		return "", "", err
	}
	return
}
func ( le * LetsEncrypt ) FinalizeOrder ( order * acme . Order , domain string , privCertKey crypto . Signer ) ( privKey string , certificate string , err error ) { if privCertKey == nil { privCertKey , err = rsa . GenerateKey ( rand . Reader , 2048 ) if err != nil { return " " , " " , err } } req := & x509 . CertificateRequest { Subject : pkix . Name { CommonName : domain } , } csr , err := x509 . CreateCertificateRequest ( rand . Reader , req , privCertKey ) if err != nil { return " " , " " , err } certs , _ , err := le . AcmeClient . CreateOrderCert ( le . Ctx , order . FinalizeURL , csr , true ) if err != nil { return " " , " " , err } for _ , cert := range certs { c , err := x509 . ParseCertificate ( cert ) if err != nil { return " " , " " , err } var b bytes . Buffer err = pem . Encode ( & b , & pem . Block { Type : " " , Bytes : c . Raw } ) if err != nil { return " " , " " , err } certificate += b . String ( ) } privKey , err = privKeyToPEM ( privCertKey ) if err != nil { return " " , " " , err } return }
FinalizeOrder will ask LetsEncrypt for the actual certificate by issusing a certificate order.
FinalizeOrder will ask LetsEncrypt for the actual certificate by issusing a certificate order .
// Generate a new private key if not supplied // Create CSR // Let LetsEncrypt sign the CSR and return the certificate // Convert all certificates to PEM format // Convert private and public key to PEM