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: [DBOPS-928]: SSL Connection issues with MongoDB Database DevOps #9646

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hemanthbsridhar
Copy link
Contributor

Thanks for contributing to the Harness Developer Hub! Our code owners will review your submission.

Description

  • Please describe your changes: __________________________________
  • Jira/GitHub Issue numbers (if any): ______________________________
  • Preview links/images (Internal contributors only): __________________

PR lifecycle

We aim to merge PRs within one week or less, but delays happen sometimes.

If your PR is open longer than two weeks without any human activity, please tag a code owner in a comment.

PRs must meet these requirements to be merged:

  • Successful preview build.
  • Code owner review.
  • No merge conflicts.
  • Release notes/new features docs: Feature/version released to at least one prod environment.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@@ -0,0 +1,226 @@
---
title: DB Devops MongoDB SSL
Copy link
Contributor

Choose a reason for hiding this comment

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

add this page as subpage for setup connectors

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 don't think it is a good idea to add it under setting up of connectors since it is specific to JDBC connectors.

I feel a better approach is to create SSL parent page and Mongo SSL as the sub page.

Let me know your thoughts.


### TLS

* `root_ca.crt` file is available
Copy link
Contributor

Choose a reason for hiding this comment

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

we should have prerequisites section and explain what is root_ca.crt, if not present how he can get it

Copy link
Contributor Author

@hemanthbsridhar hemanthbsridhar Mar 8, 2025

Choose a reason for hiding this comment

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

what is your opinion on creating on the below structure
SSL

  • Pre-requisites
  • MongoSSL

pre-requisites will have steps on creation of keys and common delegate configuration


#### Secret Configuration

We will create a secret with the `root_ca.crt`
Copy link
Contributor

Choose a reason for hiding this comment

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

who is we? harnss or customer should do it? if us, customer doesn't care about it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we is the customer.
Will remove the word we to remove confusion


#### Delegate Configuration

Ensure that the [common delegate configuration](#common-delegate-configuration) is done before moving on to the next steps
Copy link
Contributor

Choose a reason for hiding this comment

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

we should mention mount cert from delegate to build pods

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed


**IMPORTANT NOTE** : The value of the `DESTINATION_CA_PATH` environment variable has to be : `/etc/ssl/certs/dbops/root_ca.crt`

#### JDBC Test Connection
Copy link
Contributor

Choose a reason for hiding this comment

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

@bot-gitexp-user
Copy link

Please check the Execution Link of the Pipeline for the Website Draft URL. This is located in the Preview Step behind the Harness VPN and also is available in #hdh_alerts. E.g Website Draft URL: https://unique-id--harness-developer.netlify.app. Current Draft URL is: https://67caf11732a614391f2cfb17--harness-developer.netlify.app

@bot-gitexp-user
Copy link

Please check the Execution Link of the Pipeline for the Website Draft URL. This is located in the Preview Step behind the Harness VPN and also is available in #hdh_alerts. E.g Website Draft URL: https://unique-id--harness-developer.netlify.app. Current Draft URL is: https://67cc34fb32a61449fd2cfae6--harness-developer.netlify.app

@bot-gitexp-user
Copy link

Please check the Execution Link of the Pipeline for the Website Draft URL. This is located in the Preview Step behind the Harness VPN and also is available in #hdh_alerts. E.g Website Draft URL: https://unique-id--harness-developer.netlify.app. Current Draft URL is: https://67cc35e3e67f894b62eca011--harness-developer.netlify.app

@bot-gitexp-user
Copy link

Please check the Execution Link of the Pipeline for the Website Draft URL. This is located in the Preview Step behind the Harness VPN and also is available in #hdh_alerts. E.g Website Draft URL: https://unique-id--harness-developer.netlify.app. Current Draft URL is: https://67ceefc9b6fd7e16ba1f7afa--harness-developer.netlify.app

@bot-gitexp-user
Copy link

Please check the Execution Link of the Pipeline for the Website Draft URL. This is located in the Preview Step behind the Harness VPN and also is available in #hdh_alerts. E.g Website Draft URL: https://unique-id--harness-developer.netlify.app. Current Draft URL is: https://67cef2d2b68a7d006c423000--harness-developer.netlify.app

@bot-gitexp-user
Copy link

Please check the Execution Link of the Pipeline for the Website Draft URL. This is located in the Preview Step behind the Harness VPN and also is available in #hdh_alerts. E.g Website Draft URL: https://unique-id--harness-developer.netlify.app. Current Draft URL is: https://67cef5c05bca6c007d6df681--harness-developer.netlify.app

| **GOOGLE SPANNER** | `jdbc:cloudspanner:/projects/{project-id}/instances/{instance-id}/databases/{database-name}?lenient=true` |
| Database | JDBC URL Format |
|--------------------|----------------------------------------------------------------------------------------------------------------------------|
| **ORACLE** | `jdbc:oracle:thin:@//host:port/FREEPDB1` |
Copy link
Contributor

Choose a reason for hiding this comment

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

we should review all connection string because {} are not added at correct places to know what customer needs to replace plus what is constant

* `client.crt` and `client.key` is available
* To know more about generating client certificates, follow steps: 1 to 3 from [create_client certificate](https://developer.harness.io/docs/platform/delegates/secure-delegates/delegate-mtls-support/#create-a-client-certificate)

### Generating PKCS12
Copy link
Contributor

Choose a reason for hiding this comment

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

generating pkcs12 for client

Copy link
Contributor

Choose a reason for hiding this comment

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

lets remove pkcs for ci builds

execute the below command to generate pkcs12 file

```shell
openssl pkcs12 -export -in client.crt -inkey client.key -out client.p12 -name mongo-client -password pass:changeit
Copy link
Contributor

Choose a reason for hiding this comment

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

can we say this is step1 and base64 encode is step2.
And below step2 you can add note blue color section why we are doing so


### Secret Configuration

Create a secret using `root_ca.crt` and `client_pkcs12.txt`( base64 encoded value of the `client.p12` file )
Copy link
Contributor

Choose a reason for hiding this comment

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

this secret needs to be created on delegate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

kubernetes secret used within the delegate and mounted onto the build pods later.

Create a secret using `root_ca.crt` and `client_pkcs12.txt`( base64 encoded value of the `client.p12` file )

```shell
kubectl create secret -n namespace generic db-ops-ssl-secret --from-file root_ca.crt --from-file client_pkcs12.txt
Copy link
Contributor

Choose a reason for hiding this comment

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

did we check why we cant use this directly?

kubectl create secret -n generic client-certificate
--from-file client.crt=client.crt
--from-file client.key=client.key

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we can't upload client crt and client key to the keystore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we can only upload the pkcs12 file to the keystore.

Copy link
Contributor

Choose a reason for hiding this comment

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

what if we get both crt and key and create this pkcs on our side? then the steps remain same for customer?

For default trustStore and keyStore

```shell
- name: JAVA_TOOL_OPTIONS
Copy link
Contributor

Choose a reason for hiding this comment

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

why will we need this? if we are using default truststore and keystore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because default keystore is not set by default in the system properties unlike trustStore

Copy link
Contributor

Choose a reason for hiding this comment

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

then we should mention this path is configurable, default values should be these if you are running jdk >= 17.0.0

Copy link
Contributor

Choose a reason for hiding this comment

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

give ref to truststore override of delegate

* To know more about generating CA certificates, [create_ca certificate](https://developer.harness.io/docs/platform/delegates/secure-delegates/delegate-mtls-support/#create-a-ca-certificate)
* `client.crt` and `client.key` is available
* To know more about generating client certificates, follow steps: 1 to 3 from [create_client certificate](https://developer.harness.io/docs/platform/delegates/secure-delegates/delegate-mtls-support/#create-a-client-certificate)

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. in prequisites you can mention to use CI_MOUNT_VOLUMES only to copy cert (reason )as we need to different certs and key for mtls

after prequiisites you can add,
ssl for git clone

add steps, and add ref link

Copy link
Contributor

Choose a reason for hiding this comment

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


## Pre-requisites
* `root_ca.crt` file is available
* To know more about generating CA certificates, [create_ca certificate](https://developer.harness.io/docs/platform/delegates/secure-delegates/delegate-mtls-support/#create-a-ca-certificate)
Copy link
Contributor

Choose a reason for hiding this comment

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

add this root_ca.crt into the ca.bundle and give ref to ci docs


```shell
- name: ADDITIONAL_CERTS_PATH
value: "/opt/harness-delegate/ca-bundle/root_ca.crt"
Copy link
Contributor

@archit-harness archit-harness Mar 11, 2025

Choose a reason for hiding this comment

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

keep this till bundle path

- name: ADDITIONAL_CERTS_PATH
value: "/opt/harness-delegate/ca-bundle/root_ca.crt"
- name: CI_MOUNT_VOLUMES
value: "/opt/harness-delegate/ca-bundle/root_ca.crt:/etc/ssl/certs/dbops/root_ca.crt,/opt/harness-delegate/ca-bundle/client_pkcs12.txt:/etc/ssl/certs/dbops/client_pkcs12.txt"
Copy link
Contributor

Choose a reason for hiding this comment

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

copy bundle into root_ca.crt

value: "/opt/harness-delegate/ca-bundle/root_ca.crt:/etc/ssl/certs/dbops/root_ca.crt,/opt/harness-delegate/ca-bundle/client_pkcs12.txt:/etc/ssl/certs/dbops/client_pkcs12.txt"
```

**IMPORTANT NOTE**:
Copy link
Contributor

Choose a reason for hiding this comment

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

info note type


* The destination paths during mount in `CI_MOUNT_VOLUMES` has to be
* `/etc/ssl/certs/dbops/root_ca.crt`
* `/etc/ssl/certs/dbops/client_pkcs12.txt`
Copy link
Contributor

Choose a reason for hiding this comment

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

client and key

keytool -importcert -file /opt/harness-delegate/ca-bundle/root_ca.crt -keystore $JAVA_HOME/lib/security/cacerts -alias "mongodb_ssl" -storepass changeit -noprompt
```

The trustStore and keyStore details are added as part of `JAVA_TOOL_OPTIONS` environment variable.
Copy link
Contributor

Choose a reason for hiding this comment

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

change to use JAVA_OPTS

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.

4 participants