For HTTPClient and RestClient objects
Description
Specifies the client certificate that will be used to access the
server when sending a request.
Applies to
Syntax
|
1 |
objectname.SetClientCert ( string p12cert, string password ) |
|
1 |
objectname.SetClientCert ( string storeName, string certIssue, string certSN ) |
|
Argument |
Description |
|---|---|
|
objectname |
The name of the object from which you want to set the |
|
p12cert |
The client’s private key and public key p12 or PFX |
|
password |
Password of p12 or PFX certificate. |
|
storeName |
A string that specifies the name of the certificate
To search for a certificate, it will start from the |
|
certIssue |
A string that identifies the entity that has signed and The key-value pairs are separated by “~r~n”. |
|
certSN |
The serial number of the certificate. The issuer name and the serial number identify a unique |
Return value
Integer. The error codes are as follows:
1 — Success.
-1 — Failed to read certificate.
-2 — Failed to import certificate or the specified certificate is
not found.
-3 — The password is incorrect.
Usage
Only one client certificate can be set. If both of the above
syntaxes are executed, the one last set will overwrite the one
previously set.
You can use ClearClientCert to clear the
client certificate that is set by SetClientCert.
Examples
This example uses the certificate stored on the local directory of
the client:
|
1 2 3 4 5 |
ln_rtn = l_httpclient.SendRequest("GET", "https://test.appeon.com") If ln_rtn = -16 Then l_httpclient.SetClientCert("e:\testclient.pfx", "123456"); l_httpclient.SendRequest("GET", "https://test.appeon.com") End If |
|
1 2 3 4 5 |
ln_rtn = l_restclient.SendGetRequest("https://test.appeon.com") If ln_rtn = -27 Then l_restclient.SetClientCert("e:\testclient.pfx", "123456"); l_restclient.SendGetRequest("https://test.appeon.com") End If |
This example uses the certificate from the root certificate
store:
|
1 2 3 4 5 6 7 8 |
ln_rtn = l_httpclient.SendRequest("GET", "https://test.appeon.com") ls_certSN = "0cbe" ls_certIssue = 'CN = AAA Certificate Services~r~nO = Comodo CA Limited~r~n L = Salford~r~n S = Greater Manchester~r~n C = GB' If ln_rtn = -16 Then l_httpclient.anonymousAccess = false l_httpclient.SetClientCert("root", ls_certSN, ls_certIssue); l_httpclient.SendRequest("GET", "https://test.appeon.com") End If |
|
1 2 3 4 5 6 7 8 |
ln_rtn = l_restclient.SendGetRequest ("https://test.appeon.com") ls_certSN = "0cbe" ls_certIssue = 'CN = AAA Certificate Services~r~nO = Comodo CA Limited~r~n L = Salford~r~n S = Greater Manchester~r~n C = GB' If ln_rtn = -27 Then l_restclient.anonymousAccess = false l_restclient.SetClientCert("root", ls_certSN, ls_certIssue); l_restclient.SendGetRequest ("https://test.appeon.com") End If |
See also