When you call a web service, if the web service requires a client certificate, that is, the SSL protocol, you need to load the previous client certificate when calling the service. This client certificate is one. CER file, which can be exported from the certificate of the browser. The private key does not need to be exported during export. In this way, the exported certificate does not contain the private key, that is, copying the Certificate file to other machines is invalid.
It is relatively simple to call. As follows:
// The Path to the certificate.
String certificate = "certificate. Cer ";
// Load the certificate into an x509certificate object.
X509certificate Cert = x509certificate. createfromcertfile (certificate );
Loginservice SRV = new loginservice ();
SRV. clientcertificates. Add (CERT );
If the certificate is not loaded, the system will return the 403 forbidden access error.
In addition, to avoid the use Code To load the certificate, you can directly modify the WS proxy class, for example:
Public loginservice (){
String urlsetting = system. configuration. configurationsettings. receivettings ["loginplugin. localhost. loginservice"];
If (urlsetting! = NULL )){
This. url = string. Concat (urlsetting ,"");
}
Else {
This. url = "http: // localhost/jiancha2/services/loginservice. asmx ";
}
If (system. configuration. configurationsettings. deleettings ["SSL"] = "true" & Ocean. plugins. certinfo. Cert! = NULL)
{
This. clientcertificates. Add (ocean. plugins. certinfo. Cert );
}
}
As for how the Certificate Server and web server support SSL, I will not talk much about it in the dev-club e-Magazine.