SSL certificate files - no .ca file - web-services

I am creating an application which requires ssl cert files. It requires .crt, .key, .ca files, but I only have .crt, .key, .pem, and .p12 files. Is the .ca file required? What exactly are those files? Is it possible to obtain .ca from .pem or .p12?

The .ca file is the Certificate Authority Root Certificate. It's the certificate that all the modern browsers have already in their resource as a trusted certificate. When your web-site is requested, your web-server will send his particular certificate + the .ca certificate... and then the browser will find out that you are indeed enrolled with that particular .ca and thus are trusted.
Without this .ca file, the browsers will fail to verify you. The communication will be encrypted and ssl'ed but the user will get a scary warning that says, this site is not protected.
If you have obtained your ssl from any of the vendors, then they will definitely be able to provide you the .ca file.
Where did you get your ssl certificate from?
For each of those file types, you can very easily wiki the types and read more about it. Just so you know, the .key file is your private key and you should take care not to lose it or to keep it somewhere unprotected. If you've actually purchased an ssl certificate, then the .key should be saved and backedu p nicely. .pem and .p12 are different containers for your certificate. Please research the topic..before asking the questions. there are many many answers on StackOverflow and other places as well for this!

Related

Upload correct certificate to AWS for https

I am new in AWS and have little knowledge only for ssl. I have already bought certificate for ssl and they are like this. (file name). I buy from sslcertificate.com
But in aws panel, I saw like this to put pem value.
I am not sure which crt file I need to use. Do I need to use CSR file also? (the one that I use to have crt file).
To upload your own certificate to AWS Certificate Manager you need to provide three pieces.
Certificate Body
This is the certificate that was provided to you from your certificate authority that they have signed. This is the certificate that is unique to your website. This is what is returned to browsers when they make requests so this information is public.
In this case it is the www_test_io.crt file.
Certificate Private Key
The private key is something that you should have generated when you requested a certificate. This information must be kept secret. Keeping this secret is the key (pun intended) to how the connection is secured. Once you provide this to AWS they will never give it back to you so you may want to keep this safe on your own.
Your private key may be password protected, if it is you will have to use a command line tool to remove the password before you upload it here.
In this case the file that contains the private key was not listed, but this key is mandatory for you to be able to upload the certificate.
Certificate Chain
The certificate chain consists of the certificates that are "in-between" your certificate and the root certificate. All of this information is public, the same as your certificate. There may be zero, one, or multiple certificates in the chain. The chain is required so the clients can tie your certificate back to a root that it trusts. It is possible that not specifying a chain may work on some clients but not others so it is best to get this correct for compatibility reasons.
In this specific case you would want to put the content of the following two files in this order:
COMODORSADomainValidationSecureServerCA.crt
COMODORSAAddTrustCA.crt
All you do is take the text content of the first, copy and paste it in, and then the text content of the second, and copy and paste it right below the first.
While it is possible to also include the root certificate as part of the chain and some people do include it, it does not need to be included and is considered best practice not to actually include the root itself.
Paste www_test_io.cert contents in to Certificate body. Open the other 3 files and merge them into one (copy and paste them together) and paste that block into the Certificate chain.
You should have the private key, which was generated when you made the request. Paste it into Certificate private key

How to validate ssl certificate on amazon ELB?

I'm writing a script that loads IAM certificate to some ELB in order to check if it's valid.
When I tested it, I used an invalid private key on purpose to see if I could load it to the ELB.... and the problem - it gets loaded!
So my questions are-
How is this possible? I know for a fact that if you use AWS console you can't do something like that.
Is there a boto way to check if a cert is valid? (not using openssl, this is what I'm trying to avoid).
What exactly do you mean when you say "check if it's valid"? If you try to upload a malformed PEM file (the text of the cert isn't valid) then it will definitely throw an error since it can't decode the file. Also, if you try to upload a mismatched public & private key it will also throw an error. I just tested these sorts of cases myself and got the following error:
The private key did not match the public key provided. Please verify the key material and try again.
If you're referring to testing that a certificate is signed, authentic, and not expired, then the ELB isn't going to do any of that. According to the AWS documentation for ELBs it's perfectly fine to make use of self-signed certificates, and certs will also continue to work (whether CA signed or self-signed) even if expired. Both self-signed certs and expired certs are "valid" as far as operation of a secure SSL connection goes. Whether the cert is signed and unexpired or not is really just a means of providing authentication that it's a legitimate certificate.
If you are asking about testing if a certificate is properly signed and not expired then you would need to test for these sorts of things yourself, typically by leveraging something like openssl.

AWS: "Unable to parse certificate. Please ensure the certificate is in PEM format."

I am trying to update a wildcard certificate for EC2 instances on AWS. The service these servers belong to consists of a single server and a set of servers behind AWS ELB.
The certificate has been successfully updated and verified on the single server.
The same is true for an instance pulled up from the image the ELB uses for AutoScaling.
However, when trying to add a new certificate to the load-balancer, I get the above error. I'm sure the certificate is correct and is in PEM format. I first tried via the web console, then using the aws aim command line tools with the same result.
Anyone came across similar issue recently?
The AWS CLI requires file:// prefix for local files. For example file://private.key, file://cert_file, etc.
Just ran into the same exact issue: web console and AWS CLI reporting the same error in not being able to parse the certificate.
The error's root cause turned out to be in the private key -- converting my private key to a "RSA PRIVATE KEY" fixed the issue:
openssl rsa -in server.key -out server.key.rsa
Then, use the server.key.rsa in the private key field and leave the public cert as is.
I just spent the last hour struggling with this issue, on the web console. For sake of documenting, I would like to share what fixed the problem for me:
Ensure all keys and certs to be in RSA (as is demonstrated in Vikram's answer)
Ensure the ---- TEXT HERE ---- start and end labels are included in what you are uploading/copy-pasting into the web-console
My issue was: The RapidSSL certificates I'd purchased on Name.com, when copy-pasted into an Evernote, resulted in the conversion of newlines into spaces. I only realized this when I inputted the text into Vim, and the monospaced text wasn't aligned properly. After a series of f, [space], a, [return], I'd fixed the file in Vi and it now seems to be working. AWS' interface should be smart enough to recover from common errors such as this - nevertheless, this fixed the issue for me.
Hope this helps save an hour for somebody else :)
According to installation steps of ZeroSSL you have to copy all the content of the private.key after opening it in notepad.
The private key must start with -----BEGIN RSA PRIVATE KEY----- and end with -----END RSA PRIVATE KEY-----
I did that also with certificate.crt and the problem solved and saved successfully
You might get this or a similar error if you get ahead of yourself and paste the CSR (Certificate Signing Request) .pem file into the AWS certificate console where you should be pasting a certificate .pem file.
The CSR file typically includes REQUEST in the first line:
-----BEGIN CERTIFICATE REQUEST-----
The certificate file does not:
-----BEGIN CERTIFICATE-----

Certificate error open ssl C

I am using openssl in c to verify a certificate. Is there any way i can skip the self signed certificate error? I am getting that error for all the sites that has invalid/expired/mismatched url certificates and i am unable to detect any of the other errors.
And I use the function
SSL_CTX_load_verify_locations(ctx,0,CA_LIST)) to load CA_LIST. What does it exactly do?
The error self-signed certificate in certificate chain comes, when the root or self-signed certificate is present in the certificate list sent by the peer, but, the same is not loaded in your Trust Store.
The SSL_CTX_load_verify_locations(ctx,0,CA_LIST)) will try to load the CAs present in the path mentioned in CA_LIST.
The function prototype is int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile, const char *CApath);
The OpenSSL Help Page Says:
"If CApath is not NULL, it points to a directory containing CA certificates in PEM format. The files each contain one CA certificate. The files are looked up by the CA subject name hash value, which must hence be available. If more than one CA certificate with the same name hash value exist, the extension must be different (e.g. 9d66eef0.0, 9d66eef0.1 etc). The search is performed in the ordering of the extension number, regardless of other properties of the certificates. Use the c_rehash utility to create the necessary links.
The certificates in CApath are only looked up when required, e.g. when building the certificate chain or when actually performing the verification of a peer certificate."
You can get more information from the OpenSSL Page here.

XMLHttpRequest SXH_OPTION_SELECT_CLIENT_SSL_CERT Naming Convention and Conflicts

Does anyone know how the client certificate lookup works with XMLHttpRequest from MSXML.
When calling the setOption(SXH_OPTION_SELECT_CLIENT_SSL_CERT, ...)
I don't know the naming convention of the certificate's CN.
I have a certificate with a CN="company sa" and if I invoke it with;
setOption(SXH_OPTION_SELECT_CLIENT_SSL_CERT, "LOCAL_MACHINE\\My\\company");
everything is working correctly. But will there be a conflict if I have another certificate that has a CN like CN = "company_somethingelse"?
Thanks
The name you specify should be the full name of the certificate. There should be no naming conflict given your example.
A helpful resource:
http://download.microsoft.com/download/9/6/5/9657c01e-107f-409c-baac-7d249561629c/MSXML4SP_RelNote.htm
Specifically:
With MSXML 4.0, the client certificate can be installed in the local machine certificate store, whereas in the previous release the certificate was installed in the user's personal store. After the certificate has been installed, you can use the Certificates MMC snap-in to view the certificate. If you have multiple certificates installed, you can use the setOption method to specify the name of the certificate with a full path to the certificate.
const SXH_OPTION_SELECT_CLIENT_SSL_CERT = 3
http.setOption SXH_OPTION_SELECT_CLIENT_SSL_CERT, "LOCAL_MACHINE\My\my certificate"
The path specified refers to the registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SystemCertificates\My\Certificates.