Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing SSL Cert on an EC2 Server without any dedicated ip address

Scenario: I have an EC2 server which houses the api currently setup to accept connections from several iPads. I do not wish for network sniffers to see the JSON requests that are being exchanged between the servers and the devices. The idea is to have a secure protocol in place so that communication will be secured.

I have been told purchasing a SSL certificate is the way forward. The Amazon server instance I have running has an address in this format:

ec2-xx-xxx-xx-xxx.ap-southeast-1.compute.amazonaws.com/

this is where my web root is with all the appropriate web service files. My webservice urls look something similar to this:

ec2-xx-xxx-xx-xxx.ap-southeast-1.compute.amazonaws.com/Agent/Create

so on so forth. There is no hosting plan whatsoever (in the case that information is necessary). I have been recommended to buy an SSL Cert from http://www.Godaddy.com and have thought about getting the up to 5 multiple domains SSL certificate package.

Question: 1 What things do I need to be made aware of in order to make sure nothing fails? I have recently read that I may need to associate an elastic IP address to my instance, otherwise the IP of my instance will change on reboots? And if that is the case, that means that the SSL certificate that was used for this: ec2-xx-xxx-xx-xxx.ap-southeast-1.compute.amazonaws.com domain would no longer work since the ip address would have changed upon reboot and therefor me losing my secure domain?

Question: 2 If my thoughts in question 1 stands true, then my question would then be what is the most user friendly way or lets say, the way for beginners to create a dedicated url for my server instance (so that 1) the domain name doesnt randomly change upon server reboot (not sure when i would reboot anyway) and 2) does this mean I can have easier webservice urls that one can remember? such as.... www.pk.com/Agent/Create instead of the long ec2 ugly url?!

Any easy to follow tutorials would be very helpful. I have looked at a few articles that spoke about elastic ip address, SSL certificates, and other articles about renaming ec2 url, but I'm in a position where I dont actually know which one applies to me. lol

Hope someone can help. thanks

like image 437
Pavan Avatar asked Mar 02 '13 12:03

Pavan


People also ask

Is Dedicated IP mandatory to install a SSL certificate?

The short answer to this question is NO. A dedicated IP address is not mandatory to install an SSL/TLS Certificate.

How do I add an SSL to my EC2 instance?

There are three steps to install an SSL/TLS certificate on your EC2 Windows instance: Create a Certificate Signing Request (CSR) and request your SSL certificate. Install your SSL certificate. Assign the SSL certificate to your IIS deployment.

How do I connect to an EC2 instance without a public IP?

If the instance does not have a public IP address, you can connect to the instance over a private network using an SSH client or the EC2 Instance Connect CLI. For example, you can connect from within the same VPC or through a VPN connection, transit gateway, or Amazon Direct Connect.

Can you get an SSL certificate for a private IP address?

An SSL certificate can't be issued for Reserved IP addresses (RFC 1918 and RFC 4193 range)/ private IP addresses (IPv4, IPv6), Intranet for Internal Server Name, local server name with a non-public domain name suffix. Extended Validated (EV) SSL are not permitted to be issued for an IP address.


2 Answers

What you want to do is to get an elastic IP address. This lets you bind your instance to a particular IP address when you start it up. You can then register a hostname in DNS (Amazon don't help you with this part) and state that that hostname has the IP address that is the elastic IP address that you have registered.

The final piece is to get a server certificate (strictly, a keypair where the public part is the server certificate) that has the hostname in the CN field of its Distinguished Name, and to install that server keypair on the instance. (This is another part that Amazon don't help you with, and is in fact the same process as if you were hosting the hardware yourself.) Like that, the client

  1. looks up the hostname and gets the elastic IP address,
  2. connects and gets the server certificate, and
  3. checks the server certificate and sees that the hostname it is for is the hostname that they expected. (There's a few other checks as well, such as whether the certificate was signed by a trusted certificate authority and whether the certificate is within its validity period.)

That allows the client to trust that who they have securely connected to is who they expected to securely connect to, which is a key part of establishing trust.

What you do not do is use the AWS machine names (internal or external) in the certificate you apply for. Those change and you really do not want to trust other people's VMs.

like image 87
Donal Fellows Avatar answered Sep 27 '22 17:09

Donal Fellows


Donal's answer is the way to go. You need to explicitly register a domain and generate the SSL certificate containing the CN as that domain. Elastic IP addresses definitely are your friends in this issue. You will need them.

I added another answer in order to give another point of view: if you ever want to scale your backend solution, going that way will be more difficult. If you ever thought about adding more servers to host your web service, you should definitely set up an Elastic Load Balancer, add your instances to it, and point the domain you just registered to your Elastic Load Balancer. Then, you can purchase the SSL certificate and install it directly on your ELB, configuring SSL termination on the ELB. You will also configure the ELB so that connections arriving at port 443 will map to port 80 (or whatever port) on your servers. Don't worry, this is plain easy to set up.

Whenever you want to add more servers to your web service, it will just be a matter of setting up another EC2 instance (this process can - and should - be automated) and adding it to the ELB.

With this setup, you get rid of the need for Elastic IP addresses. All the connections go through the ELB.

like image 44
Viccari Avatar answered Sep 27 '22 17:09

Viccari