Skip to content

Resolving the TLS url issue#459

Merged
pingyu merged 3 commits intotikv:masterfrom
limbooverlambda:limbooverlambda/https-url-issue
Jun 27, 2024
Merged

Resolving the TLS url issue#459
pingyu merged 3 commits intotikv:masterfrom
limbooverlambda:limbooverlambda/https-url-issue

Conversation

@limbooverlambda
Copy link
Copy Markdown
Contributor

@limbooverlambda limbooverlambda commented Jun 17, 2024

While running the client we are running into issues where the client fails to connect to a TLS enabled PD endpoint with the error:

[WARN] [config_logging.go:287] ["rejected connection"] [remote-addr="[addr]:port"] [server-name=] [error="tls: first record does not look like a TLS handshake"]

Digging into the code, the problem seems to stem from the following logic in the client (

client-rust/src/common/security.rs

Line 80 in c6110dd

 let addr = "http://".to_string() + &SCHEME_REG.replace(addr, ""); 
)
let addr = "http://".to_string() + &SCHEME_REG.replace(addr, "");

info!("connect to rpc server at endpoint: {:?}", addr);

let mut builder = Channel::from_shared(addr)?
    .tcp_keepalive(Some(Duration::from_secs(10)))
    .keep_alive_timeout(Duration::from_secs(3));

Here SCHEME_REG is the regex to find "https" in the prefix of the address (

client-rust/src/common/security.rs

Line 19 in c6110dd

 lazy_static::lazy_static! { 
).
lazy_static::lazy_static! {
    static ref SCHEME_REG: Regex = Regex::new(r"^\s*(https?://)").unwrap();
}

This is a problem during the ssl handshake since the server is not acknowledging the requests sent to an addressed prefixed with "http" instead of "https". Adding the logic to handle these variations.

Signed-off-by: limbooverlambda <schakra1@gmail.com>
@pingyu
Copy link
Copy Markdown
Collaborator

pingyu commented Jun 22, 2024

@limbooverlambda

Thanks for your contribution !

Please fix the error of "make check" in CI.

Rest LGTM~

Signed-off-by: limbooverlambda <schakra1@gmail.com>
@limbooverlambda
Copy link
Copy Markdown
Contributor Author

@limbooverlambda

Thanks for your contribution !

Please fix the error of "make check" in CI.

Rest LGTM~

Thanks @pingyu . I fixed the issues with the formatting.

Signed-off-by: limbooverlambda <schakra1@gmail.com>
Copy link
Copy Markdown
Collaborator

@pingyu pingyu left a comment

Choose a reason for hiding this comment

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

LGTM~

@pingyu pingyu merged commit ec8dbcc into tikv:master Jun 27, 2024
yongman added a commit to pingyu/client-rust that referenced this pull request Jan 9, 2025
Signed-off-by: Ray Yan <yming0221@gmail.com>
emmanuel-keller pushed a commit to surrealdb/tikv-client that referenced this pull request May 29, 2025
Signed-off-by: Ray Yan <yming0221@gmail.com>
(cherry picked from commit 83ad811)
emmanuel-keller pushed a commit to surrealdb/tikv-client that referenced this pull request May 29, 2025
Signed-off-by: Ray Yan <yming0221@gmail.com>
(cherry picked from commit 83ad811)
pingyu pushed a commit to pingyu/client-rust that referenced this pull request Jan 25, 2026
* resolving the url issue

Signed-off-by: limbooverlambda <schakra1@gmail.com>

* fix formatting

Signed-off-by: limbooverlambda <schakra1@gmail.com>

* make check fixes

Signed-off-by: limbooverlambda <schakra1@gmail.com>

---------

Signed-off-by: limbooverlambda <schakra1@gmail.com>
Signed-off-by: Ping Yu <yuping@pingcap.com>
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.

2 participants