Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HandshakeFailure error #923

Open
cinestria opened this issue May 26, 2020 · 2 comments
Open

HandshakeFailure error #923

cinestria opened this issue May 26, 2020 · 2 comments

Comments

@cinestria
Copy link

cinestria commented May 26, 2020

I tried website crawling with this codes

use std::collections::HashMap;
use reqwest::header::USER_AGENT;
use reqwest::header::ACCEPT;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = reqwest::Client::new();
    let res = client.post("https://opendart.fss.or.kr/api/list.json")
        .header(USER_AGENT, "test")
        .header(ACCEPT, "application/json")
        .send()
        .await?;
    println!("{:#?}", res);
    Ok(())
} 

but this codes returned error.
Error: reqwest::Error { kind: Request, url: "https://opendart.fss.or.kr/api/list.json", source: hyper::Error(Connect, Custom { kind: Other, error: Custom { kind: InvalidData, error: AlertReceived(HandshakeFailure) } }) }

so then i tried another code with curl library

use std::io::{stdout, Write};

use curl::easy::Easy;
use curl::easy::List;

// Print a web page onto stdout
fn main() {
    let mut easy = Easy::new();
    let mut list = List::new();
    list.append("user-agent: test").unwrap();
    list.append("accept: application/json").unwrap();

    easy.url("https://opendart.fss.or.kr/api/list.json").unwrap();
    easy.http_headers(list).unwrap();

    easy.write_function(|data| {
        stdout().write_all(data).unwrap();
        println!("{}", data.len());
        Ok(data.len())
    }).unwrap();
    easy.perform().unwrap();    

    println!("{}", easy.response_code().unwrap());
}

this codes is fine.

I want to know why this is happening.

@Darkspirit
Copy link

https://www.hardenize.com/report/opendart.fss.or.kr/1590494615#www_tls
This server is horribly configured and does not support modern encryption. Therefore many clients won't be able to connect. If you are using Rustls, it correctly demands the use of ECDHE ciphersuites - which this server does not offer.

@cinestria
Copy link
Author

cinestria commented May 26, 2020

Thanks for your response.

In fact Korea's government sites are poor maintenance. 😂

Is there no other way than to use curl?

because i use deno lang. by the way deno use reqwest in internal deno code.

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

No branches or pull requests

2 participants