Skip to content

Commit

Permalink
Fix TLS generation script to use RSA keys instead of EC keys
Browse files Browse the repository at this point in the history
  • Loading branch information
River2000i committed Nov 19, 2024
1 parent d40822f commit 3f27bce
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 50 deletions.
21 changes: 15 additions & 6 deletions dm/tests/tls/conf/ca.pem
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
-----BEGIN CERTIFICATE-----
MIIBGDCBwAIJAOjYXLFw5V1HMAoGCCqGSM49BAMCMBQxEjAQBgNVBAMMCWxvY2Fs
aG9zdDAgFw0yMDAzMTcxMjAwMzNaGA8yMjkzMTIzMTEyMDAzM1owFDESMBAGA1UE
AwwJbG9jYWxob3N0MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEglCIJD8uVBfD
kuM+UQP+VA7Srbz17WPLA0Sqc+sQ2p6fT6HYKCW60EXiZ/yEC0925iyVbXEEbX4J
xCc2Heow5TAKBggqhkjOPQQDAgNHADBEAiAILL3Zt/3NFeDW9c9UAcJ9lc92E0ZL
GNDuH6i19Fex3wIgT0ZMAKAFSirGGtcLu0emceuk+zVKjJzmYbsLdpj/JuQ=
MIICsTCCAZkCFBW2dYDlpiY0fQo4/BbVb4kWuLGMMA0GCSqGSIb3DQEBCwUAMBQx
EjAQBgNVBAMMCWxvY2FsaG9zdDAgFw0yNDExMTkwMjUxNThaGA8yMjk4MDkwNDAy
NTE1OFowFDESMBAGA1UEAwwJbG9jYWxob3N0MIIBIjANBgkqhkiG9w0BAQEFAAOC
AQ8AMIIBCgKCAQEAzNlitARpbbz2zDeze6X70vGg5Ti0t7xz7MsAAl9ESyf6i/XD
zBDGN5w18YaPUsXbOFz5dJeWtVK8xheJCN19RwYUGWf6BGuLohCA7ygSy43ICVNJ
xeW47xev4RcACu/C2UelBaVQLleSKsMFtEwuGJTlGL9nfxR3NKw7JUYntcy0+1c9
GJQunFp8UU2ymENJqlIwhtwy5Z56oWRGS34rVdyhmlQ/OrGEinTyyoZBxWJmzbvw
Cqi1+IZKmwobGVSIuNdKxLwn/KNRxXE+tWwVy/+Dq5U3mt4zdBcRHQsSuqxPzS+6
/3MivAN+5hGebHv1UyfKEQTACyKc8YHryf5SPwIDAQABMA0GCSqGSIb3DQEBCwUA
A4IBAQCPf/9isj85Ncsw7v01apIuklLzHByYZdkD0yY3Igrw2teaOGNKcTuXHiPM
v4QpV5KkkRtL+okNR6hL1BoY4OYkDRD67b8bHqr20JiYUriA1aZ5paW2MVXya8eE
T12fZYpNuYWKfd2YQiWSUuEEhCbr6cBkw9A4oyhVx5+QAFVstysm4U4dI9fn89uK
Ywtcc0ebk7FwjwGfchKW9mGG7mSOcZdGiKxYFxnI+wIf0nwjJvRraQbNpN2RuqSx
Oc/oG8QdRklQ6GnDKEwWb4P2z4r3n16O0ntcyXt03h1pFxrGTNhQ+pwbormCmN/c
t2udn5DvywhPljodj8vnprDScR4g
-----END CERTIFICATE-----
35 changes: 27 additions & 8 deletions dm/tests/tls/conf/dm.key
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
-----BEGIN EC PARAMETERS-----
BggqhkjOPQMBBw==
-----END EC PARAMETERS-----
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEICF/GDtVxhTPTP501nOu4jgwGSDY01xN+61xd9MfChw+oAoGCCqGSM49
AwEHoUQDQgAEgQOv5bQO7xK16vZWhwJqlz2vl19+AXW2Ql7KQyGiBJVSvLbyDLOr
kIeFlHN04iqQ39SKSOSfeGSfRt6doU6IcA==
-----END EC PRIVATE KEY-----
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAuWvI0YtEvBAkO4dHtGdwRJ2aTCsB0jjWrSBz55pMn+4ht1Sl
9YECNx6+1SSenuzfDvvNkplIeI3RI+8QjS6by0yeBQxxp60Zh/HrS2CnRbjEXjig
PnLxL/xnR1MxtlzmKH3wdq0Z7jRSYwHxZ15uKvECq8wmnJuAnKyMdOc3kQYcdD/1
tAQ8HqKOZr6wVfjj4ApZuctqGN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i7yfIBlIctjPwAHncHoJhH6ODqbuMQv3gnArJTJUCbIfKf/En3K7PHyeB
ebMXVsIyPbim7xX3QO+6/ME7Bg+co1ayt/zXH8L364gj0rtZlmBifzT7j2MUA9hR
DsCxpQKBgQCvPP4d0zZTRobdJtPaLnAgMq6F0RPhzoDzVlcKqXJzcELflSvusdel
L2CPOFs8KXe2BxlJpUUwmhuTIHuwWahkMxx/Dhd5rJ9qlQtDygTKNsaJgnflPscF
mFZkIeDqpeE05X9tcvWdA+QSgpmY7AmjwvlOfCTi0Ftx1s7HPfnhTQ==
-----END RSA PRIVATE KEY-----
24 changes: 16 additions & 8 deletions dm/tests/tls/conf/dm.pem
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
-----BEGIN CERTIFICATE-----
MIIBZDCCAQqgAwIBAgIJAIT/lgXUc1JqMAoGCCqGSM49BAMCMBQxEjAQBgNVBAMM
CWxvY2FsaG9zdDAgFw0yMDAzMTcxMjAwMzNaGA8yMjkzMTIzMTEyMDAzM1owDTEL
MAkGA1UEAwwCZG0wWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAASBA6/ltA7vErXq
9laHAmqXPa+XX34BdbZCXspDIaIElVK8tvIMs6uQh4WUc3TiKpDf1IpI5J94ZJ9G
3p2hTohwo0owSDAaBgNVHREEEzARgglsb2NhbGhvc3SHBH8AAAEwCwYDVR0PBAQD
AgWgMB0GA1UdJQQWMBQGCCsGAQUFBwMCBggrBgEFBQcDATAKBggqhkjOPQQDAgNI
ADBFAiEAx6ljJ+tNa55ypWLGNqmXlB4UdMmKmE4RSKJ8mmEelfECIG2ZmCE59rv5
wImM6KnK+vM2QnEiISH3PeYyyRzQzycu
MIIC+zCCAeOgAwIBAgIUDg53fesx1gIIYkGiIDbjngxBd40wDQYJKoZIhvcNAQEL
BQAwFDESMBAGA1UEAwwJbG9jYWxob3N0MCAXDTI0MTExOTAyNTIxOFoYDzIyOTgw
OTA0MDI1MjE4WjANMQswCQYDVQQDDAJkbTCCASIwDQYJKoZIhvcNAQEBBQADggEP
ADCCAQoCggEBALlryNGLRLwQJDuHR7RncESdmkwrAdI41q0gc+eaTJ/uIbdUpfWB
AjcevtUknp7s3w77zZKZSHiN0SPvEI0um8tMngUMcaetGYfx60tgp0W4xF44oD5y
8S/8Z0dTMbZc5ih98HatGe40UmMB8WdebirxAqvMJpybgJysjHTnN5EGHHQ/9bQE
PB6ijma+sFX44+AKWbnLahjTppIgoDVC5Y0KoYlW3cfaPsUwMfrwcR6VG16U3wWW
APFZSofQLOsMEGzVuRoDiLRmp7pRJWUWqvEJf7JPphFbjZZKMJ5EIJrS/8Z2xx1H
oZ/zroKIKznEejGQJBLsTf0pdN1U2x18T9ECAwEAAaNKMEgwGgYDVR0RBBMwEYIJ
bG9jYWxob3N0hwR/AAABMAsGA1UdDwQEAwIFoDAdBgNVHSUEFjAUBggrBgEFBQcD
AgYIKwYBBQUHAwEwDQYJKoZIhvcNAQELBQADggEBADMC8yK209WqhIBB+48kxpgU
aIxpu1CJXCHU3M476mZFYXpzfGQvxHJJSzLb6ZdfvK2TruWd1STwlnDanAH9MAxI
nFDtI7TLlpBvtSu9SB8fQLeEY5QUl5ZtBHpLKXkVQ/GMOWKP4q7L7zE7gaeaiVlC
VcvEF/+yeaj/GBu0RE5ia23V1HbthRLcyZnGvTYsyEVwTf+ZbJso3hbbN83WaKiL
avXD267fnfeJbL0No24QWFud/og28pdS1fM7ssyZZYI9k2VlrDPQF2jHQRfIu/bt
NyTNSt8etReb1rYCNKsFK8IPTkWwJmyOCDF+dhFLgA/z9KY2MZh1M+9gR9I5GNY=
-----END CERTIFICATE-----
4 changes: 2 additions & 2 deletions dm/tests/tls/conf/generate_tls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ DNS.1 = localhost
IP.1 = 127.0.0.1
EOF

openssl ecparam -out "ca.key" -name prime256v1 -genkey
openssl genrsa -out "ca.key"
openssl req -new -batch -sha256 -subj '/CN=localhost' -key "ca.key" -out "ca.csr"
openssl x509 -req -sha256 -days 100000 -in "ca.csr" -signkey "ca.key" -out "ca.pem" 2>/dev/null

for role in dm other; do
openssl ecparam -out "$role.key" -name prime256v1 -genkey
openssl genrsa -out "$role.key"
openssl req -new -batch -sha256 -subj "/CN=${role}" -key "$role.key" -out "$role.csr"
openssl x509 -req -sha256 -days 100000 -extensions EXT -extfile "ipsan.cnf" -in "$role.csr" -CA "ca.pem" -CAkey "ca.key" -CAcreateserial -out "$role.pem" 2>/dev/null
done
35 changes: 27 additions & 8 deletions dm/tests/tls/conf/other.key
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
-----BEGIN EC PARAMETERS-----
BggqhkjOPQMBBw==
-----END EC PARAMETERS-----
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEICzbWZZ7dtha0lGXlBiP3QjCurPs5ExsR5thIQCcKCKeoAoGCCqGSM49
AwEHoUQDQgAEt5z9ACtEnsqv0ZPFx5YJhvBNQZJCEb75ZS/kDBiPoISea1HMt1w8
4ZkeWW+SBCwt0RtwzVPRq9VUGWaFRUOwdQ==
-----END EC PRIVATE KEY-----
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAw1kLMqpCyhCuviPrJkQFoZIO4ocbZO/WPju2L1B9o3QEaqzF
Zs7jTCVVtLynryw12OSay+t2JuTED4hHfSlR0RjjfHj2rV9CRyLty5Njf2ZrmX+V
pUNV/c1AKo4ACZbjy7UpQZ0dQEA6bHE3THq7oLEhREL0/QkZKOEoy8CEZ8Bk2DaR
eOepFzNX9ZSuFZ/Kfljl9skJ3D/0Sg0RjGeIddhITbW8SuR7NEEcHbjweEYCuoMr
W+90FYBx0GxAACAqzyO+QzsWaq7WbDkUYeEJjwCZ9jJthYsXGnfwpLde9A4poJs5
8LvHLq1KqDOuVXdyjQFBjZLWBVQfOTdbvzTenwIDAQABAoIBACO6G1Qu03xFRNA9
nXooIqeEIPjJIPd67cIABbftjqzgQRaJdqjw2Z1Jjr05a6mb+lUqqiz1aWx/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fW8pQWRxQh2BguryHYROJsXA0aVNgQPHmBLz49
V6UOSgXetUnm9TSkSGcMKDt93NwN1e6sJ3OJruAMTG3Y6guKN20sTg==
-----END RSA PRIVATE KEY-----
25 changes: 17 additions & 8 deletions dm/tests/tls/conf/other.pem
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
-----BEGIN CERTIFICATE-----
MIIBZzCCAQ2gAwIBAgIJAIT/lgXUc1JrMAoGCCqGSM49BAMCMBQxEjAQBgNVBAMM
CWxvY2FsaG9zdDAgFw0yMDAzMTcxMjAwMzNaGA8yMjkzMTIzMTEyMDAzM1owEDEO
MAwGA1UEAwwFb3RoZXIwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAS3nP0AK0Se
yq/Rk8XHlgmG8E1BkkIRvvllL+QMGI+ghJ5rUcy3XDzhmR5Zb5IELC3RG3DNU9Gr
1VQZZoVFQ7B1o0owSDAaBgNVHREEEzARgglsb2NhbGhvc3SHBH8AAAEwCwYDVR0P
BAQDAgWgMB0GA1UdJQQWMBQGCCsGAQUFBwMCBggrBgEFBQcDATAKBggqhkjOPQQD
AgNIADBFAiEA34/Vz7SaJWqYOgOLyr+y1OwiT9R7yTgBQCSSvGC+HpsCIA20BhNe
RnicYz+9qOQRxAFP1wpIyMMgOK4tKuZhx+/J
MIIC/jCCAeagAwIBAgIUDg53fesx1gIIYkGiIDbjngxBd4wwDQYJKoZIhvcNAQEL
BQAwFDESMBAGA1UEAwwJbG9jYWxob3N0MCAXDTI0MTExOTAyNTE0M1oYDzIyOTgw
OTA0MDI1MTQzWjAQMQ4wDAYDVQQDDAVvdGhlcjCCASIwDQYJKoZIhvcNAQEBBQAD
ggEPADCCAQoCggEBAMNZCzKqQsoQrr4j6yZEBaGSDuKHG2Tv1j47ti9QfaN0BGqs
xWbO40wlVbS8p68sNdjkmsvrdibkxA+IR30pUdEY43x49q1fQkci7cuTY39ma5l/
laVDVf3NQCqOAAmW48u1KUGdHUBAOmxxN0x6u6CxIURC9P0JGSjhKMvAhGfAZNg2
kXjnqRczV/WUrhWfyn5Y5fbJCdw/9EoNEYxniHXYSE21vErkezRBHB248HhGArqD
K1vvdBWAcdBsQAAgKs8jvkM7Fmqu1mw5FGHhCY8AmfYybYWLFxp38KS3XvQOKaCb
OfC7xy6tSqgzrlV3co0BQY2S1gVUHzk3W7803p8CAwEAAaNKMEgwGgYDVR0RBBMw
EYIJbG9jYWxob3N0hwR/AAABMAsGA1UdDwQEAwIFoDAdBgNVHSUEFjAUBggrBgEF
BQcDAgYIKwYBBQUHAwEwDQYJKoZIhvcNAQELBQADggEBAKaIFX66bIZRaiaLoQqw
nvremDwYX16RTDRXPmF8Jp0Rs7Xm8WeQF4B4HDhwWtkti9muecN2CzeYTlgzkbaK
yMG2mndmbO/W6pWuWObrRZF9TA+4jIQ/r5NuBcoVLwe0s4/EWxPqZyndNxBZCNr+
cpUlcG4QScrFfuj87K6yi+z1t7w0F1YMoRt0uD2MspWG2TQv7tR1iWMQRy9rVF9E
+GWEMPQRdMAG1fkTtlRd+VgcZXGWF7XEYWK0nSIBBXJf9mQGsl6XZcBqRMY2vgTa
Jk0Nix/aUsVP1cclVNQ9vL5qWUBnr9/3TseyqHcKFOrM+E6+vXFlVs33WJ2awwqP
HZ4=
-----END CERTIFICATE-----
20 changes: 10 additions & 10 deletions dm/tests/tls/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function get_mysql_ssl_data_path() {

function setup_tidb_with_tls() {
echo "run a new tidb server with tls"
cat - >"$WORK_DIR/tidb-tls-config.toml" <<EOF
cat - >"/dm/tidb-tls-config.toml" <<EOF
socket = "/tmp/tidb-tls.sock"
Expand All @@ -26,20 +26,20 @@ status-port = 10090
[security]
# set the path for certificates. Empty string means disabling secure connections.
ssl-ca = "$cur/conf/ca.pem"
ssl-cert = "$cur/conf/dm.pem"
ssl-key = "$cur/conf/dm.key"
cluster-ssl-ca = "$cur/conf/ca.pem"
cluster-ssl-cert = "$cur/conf/dm.pem"
cluster-ssl-key = "$cur/conf/dm.key"
ssl-ca = "/dm/tiflow/dm/tests/tls/conf/ca.pem"
ssl-cert = "/dm/tiflow/dm/tests/tls/conf/dm.pem"
ssl-key = "/dm/tiflow/dm/tests/tls/conf/dm.key"
cluster-ssl-ca = "/dm/tiflow/dm/tests/tls/conf/ca.pem"
cluster-ssl-cert = "/dm/tiflow/dm/tests/tls/conf/dm.pem"
cluster-ssl-key = "/dm/tiflow/dm/tests/tls/conf/dm.key"
EOF

bin/tidb-server \
-P 4400 \
--path $WORK_DIR/tidb \
--path /dm/tidb \
--store unistore \
--config $WORK_DIR/tidb-tls-config.toml \
--log-file "$WORK_DIR/tidb.log" 2>&1 &
--config /dm/tidb-tls-config.toml \
--log-file "dm/tidb.log" 2>&1 &

sleep 5
ls -alh $cur/conf
Expand Down

0 comments on commit 3f27bce

Please sign in to comment.