How to create pfx certificate
How to create a self-signed certificate that can be used to sign MS-Office VBA projects (Excel/Word macros) on multiple computers
Problem: When a certificate is created by using selfcert.exe, it's private key cannot be exported. The export wizard of the Windows certificate console says "the associated private key is marked as not exportable".
Solution version 1: Use makecert.exe with the "-pe" option to create and store the certificate with an exportable private key:
Then you can export the certificate from the Windows certificate store, including the private key.
Note : Old versions of makecert.exe do not support the "-pe" option. The .NET Framework SDK 2.0 and the October 2002 version of the Platform SDK (build 3718.1) contain a
new version of makecert.exe (5.131) that supports the "-pe" option.
(The .NET Framework SDKs 1.0 and 1.1 both contain old versions of makecert.exe that do not support the "-pe" option).
Solution version 2: The following commands can be used to create a PFX file (PKCS #12) that contains the a self-signed certificate together with the associated private key:
The last command (pvkimprt -pfx) creates the file selfcert.pfx. This PFX file can then be imported into the Windows certificate store and used for code signing.
(makecert .exe and cert2spc .exe are part of several Microsoft SDKs, e.g. the Platform SDK or the DotNet SDKs. which can be downloaded from microsoft.com. pvkimprt .exe can be downloaded individually from Microsoft.)Source: www.source-code.biz