1+ # ===================================================================
2+ # GitHub Action: SSL Certificate Validation Test with Squid Proxy
3+ #
4+ # Purpose:
5+ # This workflow simulates real-world SSL trust chain configurations
6+ # to validate JDBC driver support for:
7+ # - Custom trust stores
8+ # - System trust stores
9+ # - Self-signed certificate handling
10+ # - Revocation and fallback behavior
11+ #
12+ # How:
13+ # - Generates a Root CA, Intermediate CA, and signs a server cert (mirroring real world use-cases)
14+ # - Starts a Squid HTTPS proxy using the signed cert
15+ # - Creates a Java truststore with the correct anchors
16+ # - Optionally installs the Root CA into system trust store
17+ # - Runs targeted JDBC integration tests using SSLTest.java
18+ # ===================================================================1
19+
20+ name : SSL Certificate Validation Test with Squid Proxy
21+
22+ on :
23+ workflow_dispatch :
24+ pull_request :
25+
26+ jobs :
27+ ssl-test :
28+ runs-on :
29+ group : databricks-protected-runner-group
30+ labels : linux-ubuntu-latest
31+
32+ steps :
33+ - name : Checkout
34+ uses : actions/checkout@v4
35+
36+ - name : Set Up Java
37+ uses : actions/setup-java@v4
38+ with :
39+ java-version : " 21"
40+ distribution : " adopt"
41+
42+ - name : Install Squid and SSL Tools
43+ run : |
44+ sudo apt-get update
45+ sudo apt-get install -y squid openssl libnss3-tools ca-certificates
46+
47+ - name : Create Root CA and Certificates
48+ run : |
49+ mkdir -p /tmp/ssl-certs
50+ cd /tmp/ssl-certs
51+
52+ # Generate Root CA
53+ openssl genrsa -out rootCA.key 4096
54+ openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 365 -out rootCA.crt \
55+ -subj "/C=US/ST=California/L=San Francisco/O=Databricks Test/OU=Testing/CN=Databricks Test Root CA"
56+
57+ # Generate Intermediate CA
58+ openssl genrsa -out intermediateCA.key 4096
59+ openssl req -new -key intermediateCA.key -out intermediateCA.csr \
60+ -subj "/C=US/ST=California/L=San Francisco/O=Databricks Test/OU=Testing/CN=Databricks Test Intermediate CA"
61+
62+ # Create extension file for intermediate CA
63+ cat > intermediate_ext.cnf << EOF
64+ [ v3_ca ]
65+ subjectKeyIdentifier = hash
66+ authorityKeyIdentifier = keyid:always,issuer
67+ basicConstraints = critical, CA:true, pathlen:0
68+ keyUsage = critical, digitalSignature, cRLSign, keyCertSign
69+ EOF
70+
71+ # Sign Intermediate CA with Root CA
72+ openssl x509 -req -in intermediateCA.csr -CA rootCA.crt -CAkey rootCA.key \
73+ -CAcreateserial -out intermediateCA.crt -days 365 -sha256 \
74+ -extfile intermediate_ext.cnf -extensions v3_ca
75+
76+ # Generate Squid Proxy Certificate
77+ openssl genrsa -out squid.key 2048
78+ openssl req -new -key squid.key -out squid.csr \
79+ -subj "/C=US/ST=California/L=San Francisco/O=Databricks Test/OU=Testing/CN=localhost"
80+
81+ # Create extension file for Squid certificate
82+ cat > squid_ext.cnf << EOF
83+ [ v3_req ]
84+ basicConstraints = CA:FALSE
85+ keyUsage = digitalSignature, keyEncipherment
86+ extendedKeyUsage = serverAuth
87+ subjectAltName = @alt_names
88+
89+ [alt_names]
90+ DNS.1 = localhost
91+ IP.1 = 127.0.0.1
92+ EOF
93+
94+ # Sign Squid certificate with Intermediate CA
95+ openssl x509 -req -in squid.csr -CA intermediateCA.crt -CAkey intermediateCA.key \
96+ -CAcreateserial -out squid.crt -days 365 -sha256 \
97+ -extfile squid_ext.cnf -extensions v3_req
98+
99+ # Create PEM file for Squid
100+ cat squid.crt squid.key > squid.pem
101+ chmod 400 squid.pem
102+
103+ # Copy to appropriate locations
104+ sudo cp squid.pem /etc/squid/
105+ sudo chown proxy:proxy /etc/squid/squid.pem
106+
107+ # Create Java Keystore from Root CA - with proper trust anchors
108+ rm -f test-truststore.jks
109+
110+ # Create a truststore with the root CA as a trusted certificate entry
111+ keytool -importcert -noprompt -trustcacerts -alias rootca -file rootCA.crt \
112+ -keystore test-truststore.jks -storepass changeit
113+
114+ # Also add the intermediate CA to the trust store
115+ keytool -importcert -noprompt -trustcacerts -alias intermediateca -file intermediateCA.crt \
116+ -keystore test-truststore.jks -storepass changeit
117+
118+ chmod 644 test-truststore.jks
119+
120+ - name : Configure Squid with Standard SSL
121+ run : |
122+ sudo cp /etc/squid/squid.conf /etc/squid/squid.conf.orig
123+
124+ echo "
125+ # Basic Configuration
126+ http_port 3128
127+
128+ # Plain HTTPS port with certificate
129+ https_port 3129 tls-cert=/etc/squid/squid.pem
130+
131+ # Access Control - very permissive for testing
132+ http_access allow all
133+ always_direct allow all
134+
135+ # Avoid DNS issues in test environment
136+ dns_v4_first on
137+
138+ # Disable caching for testing
139+ cache deny all
140+
141+ # Logging
142+ debug_options ALL,1
143+ logfile_rotate 0
144+ cache_log /var/log/squid/cache.log
145+ access_log /var/log/squid/access.log squid
146+ " | sudo tee /etc/squid/squid.conf
147+
148+ sudo mkdir -p /var/log/squid
149+ sudo chown -R proxy:proxy /var/log/squid
150+ sudo chmod 755 /var/log/squid
151+
152+ sudo squid -k parse || echo "Configuration has issues but we'll try to run it anyway"
153+
154+ - name : Start Squid Proxy
155+ run : |
156+ sudo systemctl stop squid || true
157+ sudo pkill squid || true
158+
159+ sudo squid -N -d 3 -f /etc/squid/squid.conf &
160+
161+ sleep 5
162+ ps aux | grep squid
163+
164+ - name : Wait for Squid to be Ready
165+ run : |
166+ for i in {1..5}; do
167+ if curl -v -x http://localhost:3128 http://databricks.com -m 10 -o /dev/null; then
168+ echo "HTTP proxy on 3128 is working!"
169+ break
170+ fi
171+
172+ sleep 3
173+ done
174+
175+ if ps aux | grep -v grep | grep squid > /dev/null; then
176+ echo "Squid is running"
177+ else
178+ echo "Squid is not running! Attempting restart..."
179+ sudo squid -N -d 3 -f /etc/squid/squid.conf &
180+ sleep 5
181+ fi
182+
183+ - name : Install Root CA in System Trust Store
184+ run : |
185+ sudo cp /tmp/ssl-certs/rootCA.crt /usr/local/share/ca-certificates/databricks-test-rootca.crt
186+ sudo update-ca-certificates
187+
188+ - name : Maven Build
189+ run : |
190+ mvn clean package -DskipTests
191+
192+ - name : Set Environment Variables
193+ env :
194+ DATABRICKS_TOKEN : ${{ secrets.DATABRICKS_TOKEN }}
195+ DATABRICKS_HOST : ${{ secrets.DATABRICKS_HOST }}
196+ DATABRICKS_HTTP_PATH : ${{ secrets.DATABRICKS_HTTP_PATH }}
197+ HTTP_PROXY_URL : " http://localhost:3128"
198+ HTTPS_PROXY_URL : " https://localhost:3129"
199+ TRUSTSTORE_PATH : " /tmp/ssl-certs/test-truststore.jks"
200+ TRUSTSTORE_PASSWORD : " changeit"
201+ run : |
202+ echo "DATABRICKS_TOKEN=${DATABRICKS_TOKEN}" >> $GITHUB_ENV
203+ echo "DATABRICKS_HOST=${DATABRICKS_HOST}" >> $GITHUB_ENV
204+ echo "DATABRICKS_HTTP_PATH=${DATABRICKS_HTTP_PATH}" >> $GITHUB_ENV
205+ echo "HTTP_PROXY_URL=${HTTP_PROXY_URL}" >> $GITHUB_ENV
206+ echo "HTTPS_PROXY_URL=${HTTPS_PROXY_URL}" >> $GITHUB_ENV
207+ echo "TRUSTSTORE_PATH=${TRUSTSTORE_PATH}" >> $GITHUB_ENV
208+ echo "TRUSTSTORE_PASSWORD=${TRUSTSTORE_PASSWORD}" >> $GITHUB_ENV
209+
210+ - name : Run SSL Tests
211+ run : |
212+ mvn test -Dtest=**/SSLTest.java
213+
214+ - name : Cleanup
215+ if : always()
216+ run : |
217+ sudo systemctl stop squid
218+ sudo systemctl disable squid
219+ sudo pkill squid
220+ sudo rm -f /usr/local/share/ca-certificates/databricks-test-rootca.crt
221+ sudo update-ca-certificates --fresh
0 commit comments