Ezhttp How certificates are deployed when using the HTTPS protocol

Source: Internet
Author: User

Added HTTPS support for Ezhttp today, Ezhttp Introduction here: Using the EZHTTP framework to develop the CS light application based on the HTTP protocol

A self-signed certificate is created when the server starts and binds it to the port corresponding to the boot parameter URL.

The CER file exported by the server (the public key portion of the certificate) is located in the server-side program run directory.

Copy the file to the client directory and invoke the initialization function that specifies the certificate file.

Q: Why do I need to manually deploy without using the Client connection server to automatically download?

A: Because it is a self-signed certificate, the risk of hijacking is transmitted through the standard HTTP protocol.

such as 12306, the intermediary can forge a name and create the same time as the certificate substitution to deceive the client.

So if the client is published, it is best to package it when the client program is packaged.

Deployment method

No additional processing is required on the server side.

After the CER file is copied to the client directory, the client is initialized by calling the following method.

Ezclient.initialize ("https://127.0.0.1:9555/"". \\ezhttp.cer" );

Service Safety Tips

As you might all know, in general C # clients when using HTTPS requests, if the Web site certificate is an invalid certificate (self-signed, expired, etc.), we need to add a certificate callback function to determine whether to pass the server-side certificate validation

 Public Get set; }

Generally we write the tool, the callback implementation is the case, because the online code is basically the case, so more and more programs inside the callback function is so simple and rude, so this brings security issues.

Private BOOL Servercertificatevalidationcallback (object  sender, X509Certificate certificate, X509chain chain, Sslpolicyerrors sslpolicyerrors)        {            returntrue;        }

What does that mean? This means that the client accepts all server-side certificates, whether true or false.

However, this is absolutely undesirable when developing our own HTTPS-based services, especially when using self-signed certificates, where the operating system gives the client program the task of validating the server certificate through callbacks.

Our development time is to ensure that client requests are sent to our own Web service rather than to a middleman.

So, when I was developing ezhttp, I verified the legitimacy of the server by the client certificate that was exported from the server. Best practices that follow certificate validation for HTTPS-based services.

private bool Servercertificatevalidationcallback (object sender, X509Certificate certificate, X509chain chain, Sslpolicyerrors sslpolicyerrors)

{
var data = certificate. Getrawcertdata ();
return EzClient.Certs.Any (x = x.sequenceequal (data));
}

Ezhttp How certificates are deployed when using the HTTPS protocol

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.