How to bind custom SSL certificate to Service Fabric cluster management endpoint? - azure

I have an Azure Service Fabric cluster running with management endpoint https://mysf.westeurope.cloudapp.azure.com:19080/Explorer.
And I have a CNAME record:
sf.mycoolcluster.nl --> mysf.westeurope.cloudapp.azure.com and a valid certificate for sf.mycoolcluster.nl.
What I would like is to go to https://sf.mycoolcluster.nl:19080/Explorer and see my own certificate being served. However, I see no way of binding my certificate to port 19080 on the cluster so this doesn't happen.
I already configured my own certificate as the secondary SF certificate via the cluster ARM template and started using this certificate everywhere the primary certificate was used. This works fine. But still the (old) primary certificate is used by the management endpoint, resulting in a certificate validation error.

You need to setup secondary certificate by ARM template deployment, then You need to change primary with secondary (Swap) , wait 30min, delete the secondary and wait 30 min. All described here https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-cluster-security-update-certs-azure

Related

Azure Application gateway with lets encrypt

I have an AKS cluster running running Internal nginx ingress + cert-manager which generates lets encrypt for ssl terminations.
I would like to include application gateway as an entry point, where I expect that SSL internet traffic hits Applicatiom Gateway and traffic is forwarded to the nginx ingress, then to my application. I do not mind if SSL offloading is done at Appgw level or on the AKS cluster itself.
One of my biggest headaches is that Application gateway requires a certificate when an https listener is created. Since the certifiate is generated automatically on the AKS cluster I do not see the benefit of supplying an SSL certificate to the Application Gateway neither do I want to go through the extra work of generating a certificate and storing it keyvault etc etc.
What is the neatest way to tackle this problem? Potential solutions I have considered are
Configure Application Gateway to passthrough SSL to the AKS cluster
Somehow configure cert-manager to store the certificate in keyvault
The only options I see are (but I like neither are)
Purchase a certificate and store it in keyvault (however I prefer using Lets Encrypt)
Generate the SSL certificate on a cluster and then write a script which scrapes the certificate and stores it in Azure Key Vault
Any help will be appreciated
As per this tutorial here you can use cert-manager an AKS add-on that automates the creation and management of certificates.
You can also go through this tutorial which uses Azure automation runbook to automate certificate rotation for ApGw.
Since the above hasn't solution hasn't really helped me, I had decided to write an aks cron job which syncs certificates to azure keyvault.
If anyone is interested, I would be able to open source it.

Create App Service Managed Certificates by Azure

I want to create certification by App Service Managed Certificate.
I set these records
and it works correctly but when I want to create App Service Managed Certificates by Azure
I got a strange error
Failed to create App Service Managed Certificate for hostname. Click here for more details.
I try different CAA records and none of them works.
what should I do?
and if I want to use terraform it is stuck at creating the certificate
I use this template
Azure does not support the .ir domain.
Good news on App service managed certificate.
Yes, you heard correctly it became GA now and supports apex domain with a country code top-level domain (ccTLD).
Key Features:
Supports Apex domain.
Auto renewed.
Expired in 6 month.
Auto renew 45 days before expiration.
Automate using ARM template.
App Service Managed Certificate for apex domain will take a bit longer to create than for sub-domain because it uses a different validation method.
Not exportable.
I hope this will help you in securing your environment.
Maybe the tutorial you need is this:
map-a-cname-record
Create a free certificate
I had seen this error before, and solve it by the steps below:
Check the CNAME records. Map a subdomain to the app's default domain name needs two records: CNAME record and TXT record.
Make sure you enabled the CNAME record mapping in Azure .
Clear the records you don't need, like the CAA records, because wildcard certificatesis not support for creating a free certificate. Take care of the limitations.
It may takes a while for this configuration to take effect.
App Service Managed Certificate is still in Preview, there are some limitations with this (as of today), kindly check them below.
It's a private certificate to use if you just need to secure your www custom domain or any non-naked domain in App Service.
The free certificate is issued by DigiCert. For some top-level domains, you must explicitly allow DigiCert as a certificate issuer by creating a CAA domain record with the value: 0 issue digicert.com.
The free certificate comes with the following limitations:
Does not support wildcard certificates.
Does not support naked domains.
Is not exportable.
Is not supported on App Service Environment (ASE)
Does not support A records. For example, automatic renewal doesn't work with A records.
Kindly see the different between App Service Certificate and App Service Managed Certificate.
https://microsoft.github.io/AzureTipsAndTricks/blog/tip259.html
Checkout this documentation for more details.

Can't deploy to secured Service Fabric cluster from VS

I've created a secured SF cluster from the portal, but I can't connect to the explorer from the browser or deploy my app from VS. I have the cluster certificate (the one it makes you create on a Key Vault when you first deploy the cluster) installed on my machine. I got the .pfx file from the Key Vault and installed it on my Windows machine both with double click/wizard and with Powershell Import-PfxCertificate cmdlet.
Still after that, VS says Failed to contact the server. Please try again later or get help from "How to configure secure connections"
I tried added an client "admin" certificate, but it only asks me for the Thumbprint or the subject name, where I put the ones from the previously created cluster certificate. I don't really know if I need to buy a client certificate to make it work, or where do I get it?
And as I said, I can't access to the explorer using the browser either. Any ideas?
Here some screenshots:
This error message might be:
- The certificate issuer authority is not trusted
- because the certificate you installed is not valid or does not target the domain you are trying to access.
if the certificate issuer is not trusted, you might have to:
Trust then, please see this link
Or, get a new certificate from a trusted and execute the steps below
If the certificate is invalid, or misconfigured:
The message is chrome telling you that the certificate is not valid, and you can proceed on your own risk. You should be okay if you click Proceed to xyz.dev.eastus.cloudapp.com.
To deploy applications from Visual Studio to the cluster, you have to install the PFX certificate in the machine, and add the thumbprint to the publish profile file. See more in this link
How to make it work:
Register the domain you want, here I will say as www.example.com
Register the CNAME record on your DNS provider pointing to your Service Fabric default domain likexyz.dev.eastus..cloudapp.com.
Get a PFX certificate from a trusted authority, or your own self-signed certificate if it is for internal use only.
Add the certificate to key vault
Configure the VMSS to use the certificates from key vault
Update your cluster configuration with your certificate thumbprint
This link and this link provides the documentation on how to setup the cluster certificates.
And the following link has a detailed explanation how setup applications:
https://ronaldwildenberg.com/custom-domain-name-and-certificate-for-your-azure-service-fabric-cluster/
If you just want to create secure cluster for Dev and Test purposes, you could just create from the portal and let azure generate the correct certificate for you. For production workloads, you should create your certificates, Please take a look at this link for more info.

Cannot add Admin Client key to Service Fabric cluster

I am trying to add an Admin Client authentication key to my Service Fabric cluster created using the portal.
I keep getting this error (Failed to submit updates to 'admin client certificate' for cluster)-
The background - I cannot access the Service Fabric explorer after creating a cluster. I am guessing that this is because I don't have an admin client authentication set up yet.
How can I fix this error?
From my experience with Azure Service Fabric Cluster you need to have the certificate added to add client certificate. But if you set it up right should connect to it without setting new creds.
Steps below.
While setting up the cluster if its for testing you can use a self-signed certificate from Key Vault, the process can create one for you.
At the summary page of the Cluster setup you will get a link to obtain certificate as you will need that to access Fabric Cluster.
Make sure you download and install certificate (pfx) to computer's store. No password is needed.
Once the Service Fabric cluster is fully deployed click on the 'Explorer' button or the link to open portal. Make sure you are on IE or Edge because Chrome or Firefox will not like the self-signed certificate
The browser should trigger an authentication, please select the certificate we installed previous. If that is not showing as default use the more option to find it. If it's not on the list it means that certificate was not install.
That should authenticate you and give you access to the Service Fabric Cluster.
Hope this information was helpful.
You need to make sure that the SF provision is not undergoing updates first.
Also you cannot access the SF management console with the cert that was used to secure the cluster. You will need to generate a self-signed (unless you already have a CA cert) cert and use the thumbprint from that cert to import into the "Admin Client" in SF security section
This is the cert you need to also import to your client machine Cert repository

Service Fabric, which certificate do I use where?

I'm settings up a Service Fabric cluster in Azure and want to run a web API (using .NET Core) over https. I want to use my CA-signed wildcard (*.mydomain.com) certificate to access this API. But I'm a bit confused as to where I use it when I create the cluster, is it the cluster or client certificate? I'm thinking the client certificate, but the documentation states that this is for admin tools (i.e. the Explorer), so I'm unsure on how to proceed.
And yes I've read a ton of posts and resources, but I still find this confusing.
There are three certificate types. Here is a summary overview of them.
The Cluster certificate is used for the Explorer endpoint and is deployed to the primary nodes. So if you add your *.mydomain.com wildcard cert there, and CNAME something (e.g. manage.mydomain.com) to [yourcluster].[region].cloudapp.azure.com, then when you hit your management endpoint that cert will be what will be presented to the web browser.
The Reverse Proxy SSL certificate is deployed to each of the nodes and is used when using the built-in reverse proxy feature of Service Fabric. In this case this is what is being used when you hit https://api.mydomain.com/YourAppName/YourService/Resource (where api.mydomain.com is another CNAME to yourcluster.region.cloudapp.azure.com). This is used as an alternative to running your own reverse proxy or other offloading layer (Application Gateway, IIS, nginx, API Management, etc).
The Client certificates are used in place of Azure Active Directory authentication to the management endpoint. So instead of managing users in AAD (with the _Cluster AAD application and the Admin / Read-Only roles), you manage access by handing out management certificates (Admin or Read-Only) to your trusted users.
You can also have secondaries these certificates to use in certificate rollover situations.
The way we are using it is to have Application gateway configured in front of service fabric cluster, and web certificate is uploaded to Application Gateway (and dns is pointing to application gateway) In that scenario SSL is terminated at application gateway.
Another possibility is to terminate SSL at each node in service fabric cluster, in this scenario you would need to ensure that certificate gets deployed to each of the nodes.
As for cluster vs client certificate dilemma, I am also confused, but I think the answer is neither. Client certificate is not for sure since this certificate is used to identify you as admin when running service fabric admin ps scripts.
I do not think it is cluster certificate either, here is what MS docs say what it is used for:
Cluster and server certificate is required to secure a cluster and prevent unauthorized access to it. It provides cluster security in two ways:
Cluster authentication: Authenticates node-to-node communication for cluster federation. Only nodes that can prove their identity with this certificate can join the cluster.
Server authentication: Authenticates the cluster management endpoints to a management client, so that the management client knows it is talking to the real cluster. This certificate also provides an SSL for the HTTPS management API and for Service Fabric Explorer over HTTPS.
as far as I am reading into it, this certificate is used for internal cluster authentication, and it is also used so your management tools can be asured that they are working with right cluster.

Resources