How can the SSL client validate the server's certificate?

后端 未结 3 1412
夕颜
夕颜 2021-02-11 07:25

I am building an application and I am planning on using OpenSSL for securing data transfers.

I am planning on only having the client validate the server\'s certificate.

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-11 08:00

    Just to make sure we have our terminology straight, an "SSL certificate" in common parlance is really composed of two components:

    • A public certificate
    • A private key

    The public certificate component is signed by your chosen CA (certificate authority), after which it can be freely distributed. It does not need to be secured or encrypted, and indeed it will be sent to clients that connect to your server as part of the SSL negotiation.

    The private key component should be protected. In the majority of cases, this is simply stored as an encrypted file on the server. Upscale solutions use dedicated "tamperproof" crypto hardware (HSMs -- hardware security modules) to store the private key. These range from smart-card based solutions to multi-key, network enabled appliances with m/n controls etc etc. There are risks (not to mention costs) associated with HSMs that I will not go into here.

    Many applications simply retain the private key on disk. There are a couple of options to secure the key file:

    • Rely on system and file permission security (ie don't encrypt private key). For example, most ssh daemons do this.
    • Use whatever mechanism your server provides to encrypt the file - password-protected encryption is a standard feature across most web servers. (If you're rolling your own using the OpenSSL API, pick one of the obvious native key formats).

    As always, there is a security trade-off. In particular, if you are using password-protected encryption on the private key file and you experience an unexpected application restart (eg power outage), then somebody will need to be available to provide the password to the app as it restarts. Storing the password in a file that is read by system initialization scripts (as encouraged by at least two web server vendors) adds little in terms of real security. It's hard to recommend leaving the private key file unencrypted but if you are the sole admin/techy in a small shop, you should definitely consider what might happen if the server reboots when you are not available, and what the costs might be to your business.

提交回复
热议问题