Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test self-signed certificates for Che on Kubernetes/OS deployed with chectl (helm/operator installers) #14035

Closed
sleshchenko opened this issue Jul 26, 2019 · 10 comments
Assignees
Labels
kind/task Internal things, technical debt, and to-do tasks to be performed.
Milestone

Comments

@sleshchenko
Copy link
Member

sleshchenko commented Jul 26, 2019

Is your task related to a problem?

I tried to test self-signed certificate but I did manage to generate them correctly(more see #13946).
This issue is about setting up self-signed certificate for Che, and check if everything works correctly (like Java Maven workspace is started and working).

@sleshchenko sleshchenko added the kind/task Internal things, technical debt, and to-do tasks to be performed. label Jul 26, 2019
@rhopp rhopp added the status/info-needed More information is needed before the issue can move into the “analyzing” state for engineering. label Jul 26, 2019
@rhopp
Copy link
Contributor

rhopp commented Jul 26, 2019

@skabashnyuk @slemeur @sleshchenko Is this needed for 7.0?

@l0rd
Copy link
Contributor

l0rd commented Jul 30, 2019

@sleshchenko what's the relationship with #12634? I mean I thought we had fixed the issues with self-signed certs (wsmaster, plugin-broker, theia) and that we knew how to deploy Che using a self-signed cert. What's new here?

@sleshchenko
Copy link
Member Author

sleshchenko commented Jul 30, 2019

The new part is that I did not manage to generate the right wildcard self-signed certificate that would work after importing to a browser, also plugin-broker refused such a generated certificate:
Screenshot_20190725_152046

It would be nice if we have instructions list how to generate the right self-signed certificate for Che Server.

@slemeur slemeur removed the status/info-needed More information is needed before the issue can move into the “analyzing” state for engineering. label Aug 2, 2019
@slemeur slemeur changed the title Test self-signed certificates for Che on Kubernetes deployed with helm and chectl Automate tests for self-signed certificates for Che on Kubernetes deployed with helm and chectl Aug 2, 2019
@slemeur slemeur changed the title Automate tests for self-signed certificates for Che on Kubernetes deployed with helm and chectl Tests for self-signed certificates for Che on Kubernetes deployed with helm and chectl Aug 2, 2019
@sleshchenko sleshchenko changed the title Tests for self-signed certificates for Che on Kubernetes deployed with helm and chectl Test self-signed certificates for Che on Kubernetes/OS deployed with chectl (helm/operator installers) Aug 7, 2019
@sleshchenko sleshchenko self-assigned this Aug 7, 2019
@sleshchenko sleshchenko added the status/in-progress This issue has been taken by an engineer and is under active development. label Aug 7, 2019
@sleshchenko
Copy link
Member Author

sleshchenko commented Aug 9, 2019

I tried to play with generating a self-signed certificate and discovered typical issues people faced:

  1. Chrome from 58 version requires Subject Alternative Names to be set, previously Common name was fine.
  2. Firefox does not allow to use a CA certificate as a certificate for signing requests.

Here I found some meaningful instructions about generating self-signed certificates https://wiki.mozilla.org/SecurityEngineering/x509Certs and https://gist.github.com/fntlnz/cf14feb5a46b2eda428e000157447309
But it did not work for me in as-is. I modified them and got the following instructions:
Generate self-signed certs

CA_CN=minishift-signer
DOMAIN=*.192.168.99.100.nip.io

#Generate root key # add -des3 if you want to set pass phrase
openssl genrsa -out rootCA.key 4096

# Generate root cert
openssl req -x509 \
  -new -nodes \
  -key rootCA.key \
  -sha256 \
  -days 1024 \
  -out rootCA.crt \
  -subj /CN=${CA_CN} \
  -reqexts SAN \
  -extensions SAN \
  -config <(cat /etc/ssl/openssl.cnf \
      <(printf '[SAN]\nbasicConstraints=critical, CA:TRUE\nkeyUsage=keyCertSign, cRLSign, digitalSignature, keyEncipherment'))

#Create cert key for domain
openssl genrsa -out domain.key 2048

#create csr for domain
openssl req -new -sha256 \
    -key domain.key \
    -subj "/C=UA/ST=CK/O=RedHat/CN=${DOMAIN}" \
    -reqexts SAN \
    -config <(cat /etc/ssl/openssl.cnf \
        <(printf "\n[SAN]\nsubjectAltName=DNS:${DOMAIN}\nbasicConstraints=critical, CA:FALSE\nkeyUsage=keyCertSign, digitalSignature, keyEncipherment\nextendedKeyUsage=serverAuth")) \
    -out domain.csr

# create cert for domain
openssl x509 -req -extfile <(printf "subjectAltName=DNS:${DOMAIN}\nbasicConstraints=critical, CA:FALSE\nkeyUsage=keyCertSign, digitalSignature, keyEncipherment\nextendedKeyUsage=serverAuth") -days 365 -in domain.csr -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out domain.crt

After executing it, you'll be able to use domain.crt and domain.key for Route/Ingress TLS
and rootCA.crt for importing to browsers - like Chrome, Mozilla (I tested only these two).
I do not have deep knowledge in TLS and maybe some parts are not needed, but it's what works for my minishifti nstallation.

Deploy Che on Minishift
Configure Router with generated certificate:

oc login -u system:admin --insecure-skip-tls-verify=true
oc project default
oc delete secret router-certs
cat domain.crt domain.key > minishift.crt
oc create secret tls router-certs --key=domain.key --cert=minishift.crt
oc rollout latest router

Precreate a secret with self-signed certificate for Che Server.

oc create namespace che
cp rootCA.crt ca.crt
oc create secret generic self-signed-certificate --from-file=ca.crt -n=che

Deploy Che Server itself

chectl server:start --platform=minishift --installer=operator --multiuser --tls --self-signed-cert

Deploying on minikube is not fully working, I'm preparing fixes and will post PRs and instructions on how to deploy Che soon.

@sleshchenko
Copy link
Member Author

I managed to deploy Che with self-signed cert (CA + certificate for TLS) with the following changes for helm chart and chectl: #14176, che-incubator/chectl#248.
When self-signed certificates are generated (see #14035 (comment) #Generate self-signed certs
You can proceed to the following commands to deploy Che on minikube:
Deploy Che on Minikube

kubectl create namespace che
kubectl create secret tls che-tls --key=domain.key --cert=domain.crt -n che

cp rootCA.crt ca.crt
kubectl create secret generic self-signed-cert --from-file=ca.crt -n che

chectl server:start --platform=minikube --installer=helm --multiuser --tls --self-signed-cert

@benoitf benoitf modified the milestones: 7.1.0, 7.0.0 Aug 12, 2019
@benoitf
Copy link
Contributor

benoitf commented Aug 12, 2019

as Mario suggested, moving to 7.0.0 as fixes are there and PR are there

@sleshchenko
Copy link
Member Author

Helm chart is fixed to correctly deploy Che Server with self-signed-cert configured, chectl is adapted to these changes as well #14176, che-incubator/chectl#248

Also, the following issues were found but will be fixed in separate issues:

@mmorhun
Copy link
Contributor

mmorhun commented Dec 5, 2019

On Fedora openssl configuration file is located under /etc/pki/tls/openssl.cnf instead of /etc/ssl/openssl.cnf as in the Sergii's examples.
So the commands will look like:

# Generate root cert
openssl req -x509 -new -nodes  -key rootCA.key -sha256 -days 1024 -out rootCA.crt -subj /CN=${CA_CN} -reqexts SAN -extensions SAN -config <(cat /etc/pki/tls/openssl.cnf <(printf '[SAN]\nbasicConstraints=critical, CA:TRUE\nkeyUsage=keyCertSign, cRLSign, digitalSignature, keyEncipherment'))

# Create csr for domain
openssl req -new -sha256 -key domain.key -subj "/C=UA/ST=CK/O=RedHat/CN=${DOMAIN}" -reqexts SAN -config <(cat /etc/pki/tls/openssl.cnf <(printf "\n[SAN]\nsubjectAltName=DNS:${DOMAIN}\nbasicConstraints=critical, CA:FALSE\nkeyUsage=keyCertSign, digitalSignature, keyEncipherment\nextendedKeyUsage=serverAuth")) -out domain.csr

@erlansan
Copy link

erlansan commented Jul 1, 2020

Has anybody tried to create a self signed sertificate on windows to run in minishift? Is it possible to do, if so, where can i find the infos about it? All the tutorials and commands that i found so far seem to be opted for linux based OS.

@mmorhun
Copy link
Contributor

mmorhun commented Jul 7, 2021

In case one need to include root CA cert into router chain, minishift.crt should be created in the following way (docs):

cat domain.crt rootCA.crt domain.key > minishift.crt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/task Internal things, technical debt, and to-do tasks to be performed.
Projects
None yet
Development

No branches or pull requests

8 participants