CSR always invalid while sending to POST /compliance api

I’m using golang to generate CSR
Source code:

package main

import (
	"encoding/base64"
	"fmt"
	"log"
	"os"
	"os/exec"
)

func generateCSR() {
	// Create a temporary OpenSSL config file with SANs
	configFile := "openssl.cnf"
	opensslConfigContent := `
[ req ]
default_bits       = 2048
default_keyfile    = privkey.pem
distinguished_name = req_distinguished_name
req_extensions     = v3_req
prompt = no  # Disable interactive prompt

[ req_distinguished_name ]
C  = SA
O  = Maximum Speed Tech Supply LTD
OU = Riyadh Branch
CN = TST-886431145-399999999900003
emailAddress = admin@example.com

[ v3_req ]
subjectAltName = @alt_names

[ alt_names ]
DNS.1 = DirName:/SN=1-TST|2-TST|3-ed22f1d8-e6a2-1118-9b58-d9a8f11e445f/UID=399999999900003/title=1100/registeredAddress=RRRD2929/businessCategory=Supply activities
`

	// Write the config to a file
	err := os.WriteFile(configFile, []byte(opensslConfigContent), 0644)
	if err != nil {
		log.Fatalf("Failed to write OpenSSL config: %v", err)
	}
	defer os.Remove(configFile) // Clean up the config file afterward

	// OpenSSL command to generate a CSR with SANs
	cmd := exec.Command("openssl", "req", "-new", "-newkey", "rsa:2048", "-keyout", "private.key", "-out", "csr.pem", "-config", configFile, "-nodes")

	// Capture stderr and stdout to print out any error messages from OpenSSL
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr

	// Run the command
	err = cmd.Run()
	if err != nil {
		log.Fatalf("Failed to run OpenSSL command: %v", err)
	}

	// Print the generated CSR to console
	csrFile, err := os.ReadFile("csr.pem")
	if err != nil {
		log.Fatalf("Failed to read CSR file: %v", err)
	}

	fmt.Println("Generated CSR:")
	fmt.Println(string(csrFile))

	
	// Encode the CSR string to Base64
	base64CSR := base64.StdEncoding.EncodeToString(csrFile)
	fmt.Println("Base64 Encoded CSR:")
	fmt.Println(base64CSR)
}

func main() {
	generateCSR()
}

the above generate the csr:

-----BEGIN CERTIFICATE REQUEST-----
MIIDnjCCAoYCAQAwgZcxCzAJBgNVBAYTAlNBMSYwJAYD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z5
9h6BeHmboYgbWN9sWbZCKwQ1VFXuXukE4OTgbVtInGuJT13lsizG0mvsSrYebOEp
rRIQwKvRiqEd8BCaR3VL7X9yzV4o3DcKUTOue+vZLAz4dumY6Om7bvGhbGiFjm40
VmfRj8PPp6koIqInsWsZgqKG
-----END CERTIFICATE REQUEST-----

i did base64 encoding of the above obtained csr and send it to POST /compliance api
but it always giving me 400 Invalid Request. No idea what is the issue.

Dear @sirinibin2006

Thanks for reaching out, Welcome to our community.

To provide a comprehensive support can I kindly ask you to share your concerns with our support team via below mail mentioning all the steps you followed to schedule meeting if needed.

Thanks,
Ibrahem Daoud.

I see an error in the

X509v3 Subject Alternative Name section:
DNS:

image

You can try creating a CSR using the Zatca eInvoice SDK and compare it with the CSR you created with your code to see the difference.

This is not possible in Golang. im using python now and it seems working well.