如何在Golang中生成具有私钥和证书的PKCSs#12文件?

I have a base64 encoded private key and public certificate. My requirement is to create a keystore from it. From my analysis, there is no such API in Golang to create it. The other way is to generate a PKCSs#12 format file which is a keystore.

Please let me know the solution if any.

The package crypto/pkcs12 provides some basic functions for reading PKCS#12 files (it was imported from Azure/go-pkcs12, but there is currently no way to write them.

The recommended solution, for now, is use OpenSSL.

$ openssl pkcs12 -export -inkey private.key -in certificate.pem -certfile intermediates.crt -out certificate.pfx