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

Feat/grpc tls #462

Merged
merged 1 commit into from
Jan 25, 2022
Merged

Feat/grpc tls #462

merged 1 commit into from
Jan 25, 2022

Conversation

fabriziomoscon
Copy link
Contributor

@fabriziomoscon fabriziomoscon commented Dec 8, 2021

Adding TLS for grpc executor.

Remove unused option plaintext.
Add move options to grpc executor for TLS connections:

  • tls_root_ca
  • tls_client_cert
  • tls_client_key
  • ignore_verify_ssl

Is there any existing test for grpc? I didn't find it.

@fabriziomoscon fabriziomoscon force-pushed the feat/grpc-tls branch 2 times, most recently from ac64949 to fdb2d00 Compare December 8, 2021 19:18
@fsamin
Copy link
Member

fsamin commented Dec 10, 2021

Hello,
Thanks for your pull request 👍
Sadly, we don't have tests for the GRPC executor, could we ask you to add a few tests ?

@ovh-cds
Copy link
Collaborator

ovh-cds commented Dec 10, 2021

CDS Report build-venom-a#706.0 ✘

  • Build
    • Build ✔
  • Tests
    • Acceptance Tests ✘

@fabriziomoscon
Copy link
Contributor Author

@fsamin yes I will add tests. Thanks.

@fabriziomoscon
Copy link
Contributor Author

@fsamin I had a look at the other tests, and it is not clear to me how I would add this test, could you please suggest your preferred way.
Usually, we test this with a go unit test, setup creates local files for pki, the test spawn a TLS server and connects a TLS client with mutual TLS.

@fabriziomoscon
Copy link
Contributor Author

@fsamin @yesnault I have added a docker grpc server with TLS as venom-grpc.cid, which works. But I don't understand how to run venom against it. I have added a target grpc-test which uses venom_wrapper.sh to run my test locally but I receive an error:

make: *** [grpc-test] Error 127

Please let me know how would I run this test

@fabriziomoscon fabriziomoscon force-pushed the feat/grpc-tls branch 3 times, most recently from 9a01d53 to 382c4dd Compare December 21, 2021 20:03
@fsamin
Copy link
Member

fsamin commented Dec 28, 2021

Our integration tests follows the following process:

To starts all tests dependencies. We are using make start-test-stack to start all dependencies as docker containers. We are using .cid files to store containers ID. Your venom-grpc.cid target seems fine.

Once all the dependencies are up and running, we compile a specific binary of venom (with the golang tests intrumentation to be able to gather code coverage). We are using make build-test-binary-docker. It produces a venom.test file.

To run the tests we are using make run-test. Under the hood, it relies on venom_wrappers.sh. It runs all yaml files in the tests directory and if needed you can add --var-from-file flag to specify specific variables to run your tests against your grpc server.

@kravcs
Copy link

kravcs commented Jan 10, 2022

Thanks @fsamin for the instructions, the integration tests for grpc TLS are working fine from our perspective.
We also added the ability to setup TLS options with PEM files in similar way as you did for http executor.
Please let us know if everything is fine from your side as well.

@fabriziomoscon fabriziomoscon force-pushed the feat/grpc-tls branch 3 times, most recently from 719d21d to be1aaf6 Compare January 10, 2022 14:04
VENOM_VAR_MY_ENVAR=foo ./venom_wrapper.sh run -vv --format=xml --output-dir=. --lib-dir=./lib_custom --var='array_from_var=["biz","buz"]' --var-from-file ./kafka/testVariables.yml --var-from-file ./vars/vars.yml ./*.yml ./assertions/*.yml && \
run-test: generate-venom-pki
VENOM_VAR_MY_ENVAR=foo ./venom_wrapper.sh run \
-vv --format=xml --output-dir=. --lib-dir=./lib_custom --var='array_from_var=["biz","buz"]' --var-from-file ./kafka/testVariables.yml --var-from-file=$(PKI_VAR_FILE) --var-from-file ./vars/vars.yml ./*.yml ./assertions/*.yml && \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this --var-from-file=$(PKI_VAR_FILE) is needed to generate the yaml formatted PEM import file used in the test.

@fabriziomoscon
Copy link
Contributor Author

@fsamin just wanted to confirm that, as far as we can tell, we completed all the fixes for this PR. We are looking forward to read your new instructions.
Thank you

@ovh-cds
Copy link
Collaborator

ovh-cds commented Jan 24, 2022

CDS Report build-venom-a#792.0 ✘

  • Build
    • Build ✔
  • Tests
    • Acceptance Tests ✘

openssl genrsa \
-out $(PKI_DIR)/server.key 2048

# create a server Certificate Signing Request
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This step fails with the following error:

mkdir -p ./grpc/pki
# create a certificate authority (CA) that both the client and server trust.
# The CA is just a public and private key with the public key wrapped up in a self-signed X.509 certificate.
openssl req \
	-new \
	-x509 \
	-nodes \
	-days 365 \
	-subj '/C=GB/O=Example/OU=TeamA/CN=ca.example.com' \
	-keyout ./grpc/pki/ca.key \
	-out ./grpc/pki/ca.crt
3m54s234ms
Generating a RSA private key
..........................................+++++
...+++++
writing new private key to './grpc/pki/ca.key'
-----
unable to find 'distinguished_name' in config
problems making Certificate Request
139874421728576:error:0E06D06C:configuration file routines:NCONF_get_string:no value:../crypto/conf/conf_lib.c:273:group=req name=distinguished_name
make: *** [pki.mk:5: grpc/pki] Error 1

Could you handle this ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the CI on linux?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, ubuntu-20.04

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I quickly searched and found this: https://superuser.com/questions/947061/openssl-unable-to-find-distinguished-name-in-config
It looks like openssl req is not able to find a config value...
could you please let me know which openSSL version you run on ubuntu?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we don't use -subj in test, so perhaps that could be removed and see if the distinguished_name issue goes away

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried to:

  1. Run in Docker ubuntu:20.04
  2. Install openssl with apt update && apt install --yes openssl
  3. Run 2 commands and they were successful:
root@7bd2261de939:~# mkdir -p ./grpc/pki
root@7bd2261de939:~# openssl req \
> -new \
> -x509 \
> -nodes \
> -days 365 \
> -subj '/C=GB/O=Example/OU=TeamA/CN=ca.example.com' \
> -keyout ./grpc/pki/ca.key \
> -out ./grpc/pki/ca.crt
Generating a RSA private key
.........................+++++
...................................................................................................................+++++
writing new private key to './grpc/pki/ca.key'
-----

Question would be: Are you using vanilla Ubuntu 20.04 Docker image? Does it have openssl installed ? Or you use some other custom Docker image with openssl installed in some other way ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems your openssl can't find /usr/lib/ssl/openssl.cnf thus question is - is this file available on your Docker image?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sarunask @fabriziomoscon openssl fixed on your worker model. Tests are now ok. Can you rebase your PR please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@ovh-cds
Copy link
Collaborator

ovh-cds commented Jan 24, 2022

CDS Report build-venom-a#792.1 ✘

  • Build
    • Build ✔
  • Tests
    • Acceptance Tests ✘

@ovh-cds
Copy link
Collaborator

ovh-cds commented Jan 24, 2022

CDS Report build-venom-a#795.0 ✘

  • Build
    • Build ✔
  • Tests
    • Acceptance Tests ✘

@ovh-cds
Copy link
Collaborator

ovh-cds commented Jan 24, 2022

CDS Report build-venom-a#792.2 ■

  • Build
    • Build ■

1 similar comment
@ovh-cds
Copy link
Collaborator

ovh-cds commented Jan 24, 2022

CDS Report build-venom-a#792.2 ■

  • Build
    • Build ■

Fix: tidy up modules.
Remove unused option plaintext.
Add move options to grpc executor for TLS connections:
- tls_root_ca
- tls_client_cert
- tls_client_key
- ignore_verify_ssl
- grpc TLS add integration tests
- grpc TLS with PEM files support

Signed-off-by: Fabrizio Moscon <mosconfabrizio@gmail.com>
@fsamin fsamin merged commit b3ab202 into ovh:master Jan 25, 2022
@fabriziomoscon fabriziomoscon deleted the feat/grpc-tls branch January 25, 2022 08:59
@fabriziomoscon
Copy link
Contributor Author

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants