Closed
Description
etcd server version 3.4.13,
i write a demo to connect the cluster with the cert, but it get can not cannot connect
i have three nodes
node1
./etcd \
--data-dir=./data/ \
--name=etcd0 \
--cert-file=./etcd.pem \
--key-file=./etcd-key.pem \
--trusted-ca-file=./ca.pem \
--peer-cert-file=./etcd.pem \
--peer-key-file=./etcd-key.pem \
--peer-trusted-ca-file=./ca.pem \
--peer-client-cert-auth \
--client-cert-auth \
--listen-peer-urls=https://192.168.8.133:2380 \
--initial-advertise-peer-urls=https://192.168.8.133:2380 \
--listen-client-urls=https://192.168.8.133:2379,http://127.0.0.1:2379 \
--advertise-client-urls=https://192.168.8.133:2379 \
--initial-cluster-token=etcd-cluster-0 \
--initial-cluster="etcd0=https://192.168.8.133:2380,etcd1=https://192.168.8.134:2380,etcd2=https://192.168.8.135:2380" \
--initial-cluster-state=new \
--auto-compaction-mode=periodic \
--auto-compaction-retention=1 \
--max-request-bytes=33554432 \
--quota-backend-bytes=6442450944 \
--heartbeat-interval=250 \
--election-timeout=2000
node2
./etcd \
--data-dir=./data/ \
--name=etcd1 \
--cert-file=./etcd.pem \
--key-file=./etcd-key.pem \
--trusted-ca-file=./ca.pem \
--peer-cert-file=./etcd.pem \
--peer-key-file=./etcd-key.pem \
--peer-trusted-ca-file=./ca.pem \
--peer-client-cert-auth \
--client-cert-auth \
--listen-peer-urls=https://192.168.8.134:2380 \
--initial-advertise-peer-urls=https://192.168.8.134:2380 \
--listen-client-urls=https://192.168.8.134:2379,http://127.0.0.1:2379 \
--advertise-client-urls=https://192.168.8.134:2379 \
--initial-cluster-token=etcd-cluster-0 \
--initial-cluster="etcd0=https://192.168.8.133:2380,etcd1=https://192.168.8.134:2380,etcd2=https://192.168.8.135:2380" \
--initial-cluster-state=new \
--auto-compaction-mode=periodic \
--auto-compaction-retention=1 \
--max-request-bytes=33554432 \
--quota-backend-bytes=6442450944 \
--heartbeat-interval=250 \
--election-timeout=2000
node3
./etcd \
--data-dir=./data/ \
--name=etcd2 \
--cert-file=./etcd.pem \
--key-file=./etcd-key.pem \
--trusted-ca-file=./ca.pem \
--peer-cert-file=./etcd.pem \
--peer-key-file=./etcd-key.pem \
--peer-trusted-ca-file=./ca.pem \
--peer-client-cert-auth \
--client-cert-auth \
--listen-peer-urls=https://192.168.8.135:2380 \
--initial-advertise-peer-urls=https://192.168.8.135:2380 \
--listen-client-urls=https://192.168.8.135:2379,http://127.0.0.1:2379 \
--advertise-client-urls=https://192.168.8.135:2379 \
--initial-cluster-token=etcd-cluster-0 \
--initial-cluster="etcd0=https://192.168.8.133:2380,etcd1=https://192.168.8.134:2380,etcd2=https://192.168.8.135:2380" \
--initial-cluster-state=new \
--auto-compaction-mode=periodic \
--auto-compaction-retention=1 \
--max-request-bytes=33554432 \
--quota-backend-bytes=6442450944 \
--heartbeat-interval=250 \
--election-timeout=2000
i test with etcdctl, it test ok
knt@knt-20:~/work/3.4.13$ etcdctl --command-timeout=3s --cacert=./ca.pem --cert=./etcd.pem --key=./etcd-key.pem --endpoints="https://192.168.8.135:2379,https://192.168.8.134:2379,https://192.168.8.133:2379" endpoint status -w=table
+----------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
| ENDPOINT | ID | VERSION | DB SIZE | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS |
+----------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
| https://192.168.8.135:2379 | 781976c9acf7bd7 | 3.4.13 | 25 kB | true | false | 8 | 9 | 9 | |
| https://192.168.8.134:2379 | 82f03684ff969f47 | 3.4.13 | 25 kB | false | false | 8 | 9 | 9 | |
| https://192.168.8.133:2379 | c7a71eb7058e525c | 3.4.13 | 25 kB | false | false | 8 | 9 | 9 | |
+----------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
i write a demo
but cannot connect with muli-addr
#include <etcd/Client.hpp>
#include <etcd/Response.hpp>
#include <string>
#include <iostream>
int main()
{
etcd::Client* m = etcd::Client::WithSSL("https://192.168.8.133:2379,https://192.168.8.134:2379", "./ca.pem", "./etcd.pem", "./etcd-key.pem");
etcd::Response resp = m->set("foo", "test", 15).get();
printf("error_code %d, error_message %s, action %s\n", resp.error_code(),
resp.error_message().c_str(), resp.action().c_str());
}
this->channel : 0x5629620d38a0error_code 14, error_message Connect Failed, action
when i change to single addr, or, remove cert in cluster ,it is ok
#include <etcd/Client.hpp>
#include <etcd/Response.hpp>
#include <string>
#include <iostream>
int main()
{
etcd::Client* m = etcd::Client::WithSSL("https://192.168.8.133:2379", "./ca.pem", "./etcd.pem", "./etcd-key.pem");
etcd::Response resp = m->set("foo", "test", 15).get();
printf("error_code %d, error_message %s, action %s\n", resp.error_code(),
resp.error_message().c_str(), resp.action().c_str());
}
this->channel : 0x558c44b878a0error_code 0, error_message , action set