How to call web service to load certificates

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.