For TokenRequest and OAuthRequest 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.
Always returns 1.
Usage
If both of the above syntax are executed, the program will take
priority to use the certificate in the certificate store.
Examples
This example uses the certificate stored on the local directory of
the client:
|
1 2 3 4 5 |
ln_rtn = l_OAuthClient.AccessToken (lnv_TokenRequest, lnv_TokenResponse) If ln_rtn = -16 Then l_TokenRequest.SetClientCert("e:\testclient.pfx", "123456"); l_OAuthClient.AccessToken (lnv_TokenRequest, lnv_TokenResponse) End If |
|
1 2 3 4 5 |
ln_rtn = l_OAuthClient.RequestResource(lnv_OAuthRequest, lnv_ResourceResponse) If ln_rtn = -16 Then l_OAuthRequest.SetClientCert("e:\testclient.pfx", "123456"); l_OAuthClient.RequestResource(lnv_OAuthRequest, lnv_ResourceResponse) End If |
This example uses the certificate from the root certificate
store:
|
1 2 3 4 5 6 7 8 |
ln_rtn = l_OAuthClient.AccessToken (lnv_TokenRequest, lnv_TokenResponse) 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_TokenRequest.anonymousAccess = false l_TokenRequest.SetClientCert("root", ls_certSN, ls_certIssue); l_OAuthClient.AccessToken(lnv_TokenRequest, lnv_TokenResponse) End If |
|
1 2 3 4 5 6 7 8 |
ln_rtn = l_OAuthClient.RequestResource(lnv_OAuthRequest, lnv_ResourceResponse) 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_OAuthRequest.anonymousAccess = false l_OAuthRequest.SetClientCert("root", ls_certSN, ls_certIssue); l_OAuthClient.RequestResource(lnv_OAuthRequest, lnv_ResourceResponse) End If |
See also