How to Get Self Signed Certificate in Ec2 - amazon-ec2

I am working in Ec2 instance. I have connected my php files like http://13.57.220.172/phpinsert.php. But it is not secured site. So i want to convert http into https://13.57.220.172.
I have cloudflare ssl. When i try to add ssl certificate. It shows
com.amazonaws.pki.acm.exceptions.external.ValidationException: Provided certificate is not a valid self signed. Please provide either a valid self-signed certificate or certificate chain. Choose Previous button below and fix it.
i have enclose the image with it.
So how can i get the self signed certificate. is there any online tool available.

I think the error message your seeing has to do with this sentence:
If your certificate is signed by a CA, you must include the
certificate chain when you import your certificate.
from https://docs.aws.amazon.com/acm/latest/userguide/import-certificate-prerequisites.html.
Since it sounds like you're not yet in "production" mode, I'm guessing you're not particularly attached to your existing certificate, but just want a certificate to be able to do HTTPS on your web server (and don't really care if it's self-signed).
If you want to use AWS Certificate Manager, I think it would be easier to just let them (AWS) issue you a certificate instead of trying to import one from somewhere else. AWS doesn't charge anything for certificates. https://docs.aws.amazon.com/acm/latest/userguide/acm-billing.html
Even if you get the certificate setup in AWS Certificate Manager, that's not going to be installed directly on your EC2 instance, but rather (most likely) on a load balancer in front of your web server, which will add a little complexity to your setup. https://docs.aws.amazon.com/acm/latest/userguide/acm-services.html
If all you want to do is use HTTPS on your web server, Let's Encrypt (also free) is probably a simpler option. If you are using AWS Linux 2, there are instructions for getting a certificate here - https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/SSL-on-amazon-linux-2.html

Well, add to the points which #jefftrotman has already mentioned.
If your expectation is to just secure your IP address using HTTPS you can achieve that using the below approaches:
A SELF SIGNED certificate that you can create using OpenSSL.
You can also get an SSL certificate from a trust signing authority like (GoDaddy or VeriSign) or Let's encrypt.
The only requirement in the second point is that for getting a certificate from a valid signing authority you need to have a domain name like "myphpapp.com" and then use this domain to get the SSL certificate.
The below details are in case you want to use AWS ACM(Amazon Certificate Manager)
If you prefer ACM, you can get the free Public SSL certificate which you can map to the IP address and your web application will be secured.
If your requirement is to add SSL certificates (like PEM files) to a web server like
NGINX or Apache then you first need to create a Private CA using in ACM and then you using this CA you will be able to create Private SSL certificates. After creating those you can export the files and add those files to the configuration file. (try to use Amazon Linux 2) ec2 image for ease.

Related

AWS Elastic Load Balancer with HTTPS Listener. End-user browser seeing site as secure?

I want to setup a classic “Elastic Load Balancer” (ELB) in Amazon Web Services (AWS) with a HTTPS listener. This type of listener requires that you paste in private and public keys and a certificate chain.
For this question, let’s me refer to the above certificate files as private1.pem, public1.pem and certchain1.pem.
Certificate Authority #1 issued the certificate.
The application servers that will be behind this ELB will use a different private and public key and certificate chain files. Let’s refer to them as private2.pem, public2.pem and certchain2.pem.
Certificate Authority #2 issued the certificate.
When a end-user makes a call to the main website URL, is it the certificates being referenced by the application servers that will decide whether the certificate are trusted by the end-users browser? Is it correct to say, that if the end-users browser trusts the certificate authority that the application server certificates are approved by, that green pad-lock will show in end-users browser? What if the end-user browser DOES NOT trust the certificate authority for the certificate files that are being used by the ELB?
The browser will never see certificate installed on the server, in this configuration. Only the certificate on the classic ELB itself will be seen.
If the browser doesn't trust that certificate, then it doesn't trust it.
The certificate on the server is only seen by the back side of the ELB, where it can be used to (1) re-encrypt the traffic between the back-side of the balancer and the instance if the balancer is configured to expect TLS between it and the instance and (2) optionally authenticate the instance to the balancer to verify so that the balancer can prove that no impostor instances are attached to the balancer -- which is, in practice, as unlikely as it sounds but sometimes needed for compliance or policy reasons. In the second case, you provide the balancer with a copy of the instance certificate and it will connect only to an instance that is in possession of that same certificate and the matching private key. The back-end cert can be self-signed, since the trust is based on the fact that you gave the cert to the balancer for comparison, rather than the usual public trust chain mechanisms.
https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-create-https-ssl-load-balancer.html

From self managed Let's Encrypt to AWS Certificate Manager

I have been managing Let's Encrypt's SSL certificates for a domain.
Now I am moving to Amazon API gateway. I will be using the AWS Certificate Manager to generate HTTPS certificates for the root domain and a bunch of subdomains.
If I make the transfer, what happens to my current HTTPS certificate which is associated with my domain. If browsers suddenly start seeing a new HTTPS certificate for a domain, for which they had been getting a different HTTPS certificate until now, would this be a problem?
Also, once I make the shift, what do I do with my current (manually managed) Let's Encrypt certificate? Is there a way to permanently void it?
Szabolcs Dombi says
You can have multiple valid certificates for the same domain at the
same time. Moving from one certificate issuer to another should not
cause a problem.
Toby Osbourn says
SSL certificates don’t last forever, most of them need to be renewed
on a yearly cycle and occasionally you will want to change the type of
the SSL certificate mid-cycle.
Since you are replacing certificates, I suggest you to back up the ones you have.
Once you have backed up the old certificates, just overwrite the .crt and .key files with your new ones. Then, reload your web server so it knows to look at these new certificates, and you should be good to go.
If it's within your interest to know more about how to Generate SSL certificate using Amazon Certificate Manager (ACM), I suggest Barguzar, A. (July 2018). Building Serverless Python Web Services with Zappa. where one can read a good step by step guide. See an excerpt of it below:
ACM is a service that manages and creates SSL/TSL certificates for
AWS-based services and applications. An ACM certificate works with
multiple domain names and subdomains. You can also use ACM to create a
wildcard SSL.
ACM is strictly linked with AWS Certificate Manager Private
Certificate Authority (ACM PCA). ACM PCA is responsible for validating
the domain authority and issuing the certificate.
You can have multiple valid certificates for the same domain at the same time. Moving from one certificate issuer to another should not cause a problem.
This also means that if you create a new certificate the old one still can be used unless it already expired.

SSL certificate - Use Client certificate installed on server for local testing - Mutual authentication

I have been working with web services connecting to URLs provided by different clients and so far it has all been done using one-way authentication. Now I'm asked to enable 2-way (mutual) authentication for one of the clients. I did a lot of research and reading but still confused about a lot of things.
I could test successfully on my local machine following instructions from various different articles. But the problem is now to deploy it in production.
Here's what I did for testing: I created a test Web service Host and assigned it a self-signed certificate and created a client to test this. After this I created a client certificate using makecert and verified that this is installed via MMC. I then modified my Host app to only allow clients with certificate and tested from client to see the connection refused due to not providing the client certificate. Then I modified the bindings in the client application to include the certificate name and I was able to connect to the Host successfully. So this completes local hosting.
Now the real problem. The tech team is going to create a certificate in "cert store" on the server. And I need to test again to make sure everything works as expected. We have a few different developers who all want to test on their machines on their local code. Can we all use the same certificate somehow? I don't think we would be allowed to import the certificate but what suggestions could I give them so all of us can use the same certificate?
I'm also confused about issues like difference between windows certificate and IIS certificate. What advantages would the IIS certificate provide?
Thanks for help!
Edit: Could one of the differences between installing on IIS be so that the hosted sites be accessed via SSL connection? This would mean we don't really need to install on IIS if it's just a client certificate. Is this correct?

configuring CA certificates in WSO2 API Manager

I have WSO2 API manager deployed in AWS EC2 instance.
I have purchased a SSL certificate via sslforfree.com. I tried to import it via keytool command. But its not working and throwing error. It gives me
KrbException: Cannot locate default realm
How can I associate this certificate with the API Manager? I don't have a domain name for WSO2 and I access it via IP address.
Is it possible for have CA signed certificate in this case?
In case if I want a domain name for this EC2, how can I have one?
You can import the certificate inside Carbon. Log into <your_server>:9443/carbon as admin. After that go on Main -> Manage -> Keystores -> List
If you're still using the default settings you'll have the wso2carbon.jks entry here. Click on Import cert, chose your cert file and click on Import. Your certificate should be working after this.
there are several topics in this question:
I tried to import it via keytool command.But its not working and
throwing error.It gives me KrbException: Cannot locate default realm
The keytool gives you this exception? It would be useful to provide the keytool command you've used. There's not reason for that exception.
please not that the certificate CN must be the same as the fqdn (domain name) of the server (how your browser access it).
How can I associate this certificate with the API Manager?
There are two options.
Import the keypair (private key and certificate chain) into a keystore and configure the APIM to use the keystore (in the repository/conf/tomcat/catalina-server.xml)
Have a reverse proxy server (Apache HTTP, NGinx), and configure the SSL on that proxy server. This is my favorite approach .
See: https://docs.wso2.com/display/AM210/Adding+a+Reverse+Proxy+Server
Then you have control over who/where can access the carbon console, store and publisher.
I don't have a domain name for WSO2 and I access it via IP address. Is
it possible for have CA signed certificate in this case?
Certificate authorities don't provide IP based certificate, as they can validate ownership/control of a domain name, but not of the IP address.
You can create (and made trusted) your own CA and certificate (good for PoC, DEV environment, ..) but in long run you'll need a trusted certificate on a hostname.
In case if i want a domain name for this EC2 , how can i have one ?
You can always buy one :D For start - when having EC2 instance with a dynamic IP address, you may use some dynamic dns service (e.g. https://ydns.io/ , just search for more if you wish)

Using the ruby SDK, how can I get an SSL certificate signed for my AWS EC2 instance?

I have created a pem and crt file to use with my EC2 instance on AWS. I have 2 questions here:
1) The configuration instructions say: "Normally, at this stage you would submit your CSR to a Certificate Authority (CA) to apply for a digital server certificate." To whom do I send the certificate and how do I do it? Sorry, first time for me.
2) I am horribly confused about the uploading process to AWS. I have seen articles on uploading to a load balancer and uploading to IAM. I am using an EC2 instance and not, as far as I know a "load balancer" and I do not use IAM security. So how should I upload and what do I need to do?
Yours very confused seeking help ...
To get an SSL certificate signed you need to submit it to a trusted company, known as a Certificate Authority (CA). Think of your CSR like a blank cheque, nobody will trust it until it's signed by someone trustworthy.
There are commercial CAs which vary greatly in price, alternatively there are free CAs such as CACert (which I haven't used). The general process is: upload your CSR to the CA's site & the CA will provide a signed certificate.
If you want more information on what a CA's role is wikipedia is a great place to start, excerpt below:
In cryptography, a certificate authority or certification authority (CA) is an entity that issues digital certificates. A digital certificate certifies the ownership of a public key by the named subject of the certificate. This allows others (relying parties) to rely upon signatures or on assertions made by the private key that corresponds to the certified public key. In this model of trust relationships, a CA is a trusted third party – trusted both by the subject (owner) of the certificate and by the party relying upon the certificate. Many[quantify] public-key infrastructure (PKI) schemes feature CAs.
For serving SSL traffic you have two options:
A common web pattern is to "Terminate SSL at the load balancer", which just means the load balancer will host and serve the SSL certificate, then simply sends traffic to the web server (your EC2 instance) via http. This is generally considered safe as the last hop is within your infrastructure.
If you want to go without a load balancer you'll need something on the EC2 instance to serve the SSL certificate. Here again there are plenty of options but generally installing Nginx or Apache on your instance to sit in front of your app works well.
Example configuration for Apache & Nginx are plenty & you should be able to find specific instructions for what-ever language & framework you're using but they're all fairly similar.
The play framework doco has examples for both Apache & Nginx sitting in front of a web app running on the same (EC2) server on port 9000 which should work for pretty much anything running on that port.
Plenty of reading to get you on your way, hope it helps!

Resources