IPWorks WebSockets 2020 C++ Edition

Questions / Feedback?

ImportCertificate Method

Imports a certificate from a file into the current certificate store.

Syntax

ANSI (Cross Platform)
int ImportCertificate(const char* lpszCertFile, const char* lpszPassword, const char* lpszSubject);

Unicode (Windows)
INT ImportCertificate(LPCWSTR lpszCertFile, LPCWSTR lpszPassword, LPCWSTR lpszSubject);
- (void)importCertificate:(NSString*)certFile :(NSString*)password :(NSString*)subject;
#define MID_CERTMGR_IMPORTCERTIFICATE 9

IPWORKSWS_EXTERNAL int IPWORKSWS_CALL IPWorksWS_CertMgr_Do(void *lpObj, int methid, int cparam, void *param[], int cbparam[], int64 *lpllVal);

Remarks

This method will import a certificate from a file into the current certificate store.

On Windows platforms certificates may only be imported to the Windows certificate store. To load a certificate without importing it to a Windows store set Cert*.

Certificate files with or without a private key may be imported. If the file specified CertFile contains a private key the private key will be imported along with the public certificate. If the file specified by CertFile contains only a public certificate, only the public certificate will be imported.

The Password parameter specifies the certificate password (if any). When importing a public certificate set Password to empty string.

The format of the certificate file being imported must contain valid X509 data to be imported. Not all certificate file formats include X509 data such as PPK or PKCS8 private keys. If the CertFile is of a format that cannot be imported the class fails with an error.

Note: On Linux based operating system this method loads the specified certificate without importing into any system location.

Subject is optional. If empty, the first certificate in the store is loaded instead of the matching certificate.

ImportCertificate Example


//Import a PFX
certmgr.ImportCertificate("..\\test.pfx", "password", "*");
	  
//Import a public certificate (CER)
certmgr.ImportCertificate("..\\test.cer", "", "*");

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks WebSockets 2020 C++ Edition - Version 20.0 [Build 8155]