Closed Neaj-Morshad-101 closed 1 day ago
What client are you trying to use? Not all clients support TLS; you might need to contact the client author there and ask about adding support.
You can use socat
to connect to memcached when it's running TLS. There're a lot of tutorials online about how to do this.
It's also possible to use our proxy as a TLS gateway of sorts: Use your non-TLS client to connect to a proxy running on localhost, and then the proxy connects to memcached over TLS. I need to add a small guide for this as we've been working on updating the docs and I haven't gotten there yet: https://docs.memcached.org/features/proxy/ - if this could work let me know and I'll prioritize the additional guide.
We try to use > socat , but the set command is not working. Always getting "CLIENT_ERROR bad data chunk" this error. Other commands are working perfectly. Here is the logs:
socat -d -d - OPENSSL:localhost:11211,cert=/home/evan/go/src/evanraisul/memcached_TLS/client.crt,key=/home/evan/go/src/evanraisul/memcached_TLS/client.key,cafile=/home/evan/go/src/evanraisul/memcached_TLS/ca.crt,verify=1
2024/10/23 11:54:30 socat[11928] N reading from and writing to stdio 2024/10/23 11:54:30 socat[11928] W OpenSSL: Warning: this implementation does not check CRLs 2024/10/23 11:54:30 socat[11928] N successfully connected from local address AF=2 127.0.0.1:50280 2024/10/23 11:54:30 socat[11928] N trusting certificate, commonName matches 2024/10/23 11:54:30 socat[11928] N SSL proto version used: TLSv1.3 2024/10/23 11:54:30 socat[11928] N SSL connection using TLS_AES_256_GCM_SHA384 2024/10/23 11:54:30 socat[11928] N SSL connection compression "none" 2024/10/23 11:54:30 socat[11928] N SSL connection expansion "none" 2024/10/23 11:54:30 socat[11928] N starting data transfer loop with FDs [0,1] and [6,6] set foo 0 999 3 bar
CLIENT_ERROR bad data chunk 2024/10/23 11:54:45 socat[11928] N write(1, 0x60edddcfe000, 29) completed get foo END 2024/10/23 11:54:52 socat[11928] N write(1, 0x60edddcfe000, 5) completed version VERSION 1.6.31
The data portion of a set needs to end with a \r\n, which is automatically added using telnet. ie: the command is actually: set foo 0 999 3\r\n bar\r\n
guessing you're inputting \n into socat or something. you can try copy/pasting or something else; this isn't really a support forum for socat :)
you can also set up socat as a listener doing tcp<->tls and then telnet to the socat. do you need this for debugging purposes or for something else?
Actually, we want to run Memcached on Kubernetes. Already running, but need to run Memcached with TLS support. Before this we were using telnet, Memcached was running perfectly without TLS.
socat -d -d - TCP:localhost:11211
2024/10/23 13:03:55 socat[13841] N reading from and writing to stdio 2024/10/23 13:03:55 socat[13841] N opening connection to AF=2 127.0.0.1:11211 2024/10/23 13:03:55 socat[13841] N successfully connected from local address AF=2 127.0.0.1:50664 2024/10/23 13:03:55 socat[13841] N starting data transfer loop with FDs [0,1] and [5,5] version 2024/10/23 13:03:58 socat[13841] N write(5, 0x6268e8496000, 8) completed VERSION 1.6.31 2024/10/23 13:03:58 socat[13841] N write(1, 0x6268e8496000, 16) completed set foo 0 999 3\r\n bar\r\n2024/10/23 13:04:09 socat[13841] N write(5, 0x6268e8496000, 20) completed CLIENT_ERROR bad command line format 2024/10/23 13:04:09 socat[13841] N write(1, 0x6268e8496000, 38) completed version 2024/10/23 13:04:24 socat[13841] N write(5, 0x6268e8496000, 15) completed ERROR 2024/10/23 13:04:24 socat[13841] N write(1, 0x6268e8496000, 7) completed
You're just using telnet to test it right? Are you using a real client to access it normally?
You can tell memcached to listen on multiple ports, some without TLS, ie: -l 0.0.0.0:11211 -l notls:127.0.0.1:11511
if that helps?
I am using gomemcache Client to access it. But, before using that client I have to make sure that from Memcached site it is all okay and the TLS is working correctly. That's why before I was using telnet. But, telnet doesn't support TLS. So, I need "socat" or others to make sure how a normal user will connect to Memcached with TLS.
No, some ports without TLS will not help me. I need all (one or multiple) ports with TLS.
Setting up socat as a listener doing tcp<->tls and then telnet to the socat, worked successfully for Memcached with TLS Support. Thanks for the support.
Hello, I have successfully set up a Memcached server with TLS enabled. The server is running with the following configuration:
Memcached is running with the
-Z
flag to enable TLS and using the following options:ssl_chain_cert=/etc/ssl/certs/ssl_cert.pem
ssl_key=/etc/ssl/private/ssl_key.pem
Memcached version: 1.6.31
-Z
optionSteps followed:
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout ./ca.key -out ./ca.crt -subj "/CN=memcached-server/O=kubedb"
openssl genrsa -out server.key 2048
openssl req -new -key server.key -out server.csr -subj "/CN=memcached-server/O=kubedb"
openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 365
Tried connecting to the server using a client with TLS (e.g.,
openssl s_client -connect localhost:11211 -CAfile /path/to/ca.crt -servername memcached-server
).I have been using telnet to connect with memcached server, But with tls enabled, I can't connect like earlier, what flags / options are there for connecting with tls enabled? example:
I have been unable to find a way to connect to the Memcached server using TLS from available clients. It seems that there is no flag or option in the clients to establish a TLS-secured connection.
Could anyone provide guidance or information about TLS support in Memcached clients in this schenario?
Thank you!