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

Error 502 bad gateway failed to connect to host: SSL is not supported #679

Closed
subhojit777 opened this issue Jan 28, 2019 · 9 comments
Closed

Comments

@subhojit777
Copy link

I am trying to make an OAuth authentication request to GitHub. I get error when it tries to obtain an access_code from GitHub.

Error occured during request handling, status: 502 Bad Gateway Failed to connect to host: SSL is not supported

This is the code:

#[derive(Serialize, Deserialize)]
struct Body {
    client_id: String,
    client_secret: String,
    code: String,
    accept: String,
}

impl Body {
    fn new(client_id: String, client_secret: String, code: String, accept: String) -> Self {
        Body {
            client_id,
            client_secret,
            code,
            accept,
        }
    }
}

pub fn gh_redirect_callback(req: &HttpRequest<AppState>) -> Box<Future<Item = HttpResponse, Error = Error>> {
    let session_code = String::new('session_code');

    dotenv().ok();

    let github_client_id = env::var("GITHUB_CLIENT_ID").expect("GITHUB_CLIENT_ID must be set.");
    let github_client_secret = env::var("GITHUB_CLIENT_SECRET").expect("GITHUB_CLIENT_SECRET must be set.");

    let json_body = Body::new(github_client_id, github_client_secret, session_code, String::from("json"));

    client::post("https://github.com/login/oauth/access_token")
        .json(json_body).unwrap()
        .send()
        .from_err()
        .and_then(|res: ClientResponse| {
            dbg!(res);
            Ok(HttpResponse::Ok().body("inside future"))
        })
        .responder()
}

The callback URL in GitHub is set to http://127.0.0.1:8088/gh-redirect. Can you tell me what might be the issue.

@fafhrd91
Copy link
Member

Did you enable ssl feature for actix-web crate?

@subhojit777
Copy link
Author

No.

@DoumanAsh
Copy link
Contributor

Be sure to eanble one of the SSL features https://github.com/actix/actix-web/blob/master/Cargo.toml#L34-L44

@subhojit777
Copy link
Author

It worked. Thanks.

@peitalin
Copy link

Just to be clear, add this to cargo.toml:

actix-web = { version = "0.7.18", features = ["ssl"] }

@Ged0
Copy link

Ged0 commented Mar 5, 2019

error: linking with cc failed: exit code: 1
When I run example

  = note: Undefined symbols for architecture x86_64:
            "_SSLv23_method", referenced from:
                openssl::ssl::SslMethod::tls::ha97595eb573d0136 in libopenssl-66169f4e5a0a9ec5.rlib(openssl-66169f4e5a0a9ec5.openssl.1o5pd6yu-cgu.1.rcgu.o)
            "_SSL_load_error_strings", referenced from:
                openssl_sys::init::_$u7b$$u7b$closure$u7d$$u7d$::ha3c054e43f537b46 in libopenssl_sys-19a6b0094a10f644.rlib(openssl_sys-19a6b0094a10f644.openssl_sys.3vwedubj-cgu.9.rcgu.o)
            "_CRYPTO_num_locks", referenced from:
                openssl_sys::init::_$u7b$$u7b$closure$u7d$$u7d$::ha3c054e43f537b46 in libopenssl_sys-19a6b0094a10f644.rlib(openssl_sys-19a6b0094a10f644.openssl_sys.3vwedubj-cgu.9.rcgu.o)
            "_CRYPTO_set_id_callback", referenced from:
                openssl_sys::init::set_id_callback::hf85f70c33bc0a289 in libopenssl_sys-19a6b0094a10f644.rlib(openssl_sys-19a6b0094a10f644.openssl_sys.3vwedubj-cgu.9.rcgu.o)
            "_CRYPTO_set_locking_callback", referenced from:
                openssl_sys::init::_$u7b$$u7b$closure$u7d$$u7d$::ha3c054e43f537b46 in libopenssl_sys-19a6b0094a10f644.rlib(openssl_sys-19a6b0094a10f644.openssl_sys.3vwedubj-cgu.9.rcgu.o)
            "_OPENSSL_add_all_algorithms_noconf", referenced from:
                openssl_sys::init::_$u7b$$u7b$closure$u7d$$u7d$::ha3c054e43f537b46 in libopenssl_sys-19a6b0094a10f644.rlib(openssl_sys-19a6b0094a10f644.openssl_sys.3vwedubj-cgu.9.rcgu.o)
            "_SSL_library_init", referenced from:
                openssl_sys::init::_$u7b$$u7b$closure$u7d$$u7d$::ha3c054e43f537b46 in libopenssl_sys-19a6b0094a10f644.rlib(openssl_sys-19a6b0094a10f644.openssl_sys.3vwedubj-cgu.9.rcgu.o)
            "_SSLeay", referenced from:
                openssl::version::number::hb0640a49a7a65ba1 in libopenssl-66169f4e5a0a9ec5.rlib(openssl-66169f4e5a0a9ec5.openssl.1o5pd6yu-cgu.15.rcgu.o)
          ld: symbol(s) not found for architecture x86_64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

What should I do?
OS: macOS 10.14

@subhojit777
Copy link
Author

@Ged0
Copy link

Ged0 commented Mar 7, 2019

I delete the openssl 1.1 and it works now, thanks!

error: linking with cc failed: exit code: 1
When I run example

  = note: Undefined symbols for architecture x86_64:
            "_SSLv23_method", referenced from:
                openssl::ssl::SslMethod::tls::ha97595eb573d0136 in libopenssl-66169f4e5a0a9ec5.rlib(openssl-66169f4e5a0a9ec5.openssl.1o5pd6yu-cgu.1.rcgu.o)
            "_SSL_load_error_strings", referenced from:
                openssl_sys::init::_$u7b$$u7b$closure$u7d$$u7d$::ha3c054e43f537b46 in libopenssl_sys-19a6b0094a10f644.rlib(openssl_sys-19a6b0094a10f644.openssl_sys.3vwedubj-cgu.9.rcgu.o)
            "_CRYPTO_num_locks", referenced from:
                openssl_sys::init::_$u7b$$u7b$closure$u7d$$u7d$::ha3c054e43f537b46 in libopenssl_sys-19a6b0094a10f644.rlib(openssl_sys-19a6b0094a10f644.openssl_sys.3vwedubj-cgu.9.rcgu.o)
            "_CRYPTO_set_id_callback", referenced from:
                openssl_sys::init::set_id_callback::hf85f70c33bc0a289 in libopenssl_sys-19a6b0094a10f644.rlib(openssl_sys-19a6b0094a10f644.openssl_sys.3vwedubj-cgu.9.rcgu.o)
            "_CRYPTO_set_locking_callback", referenced from:
                openssl_sys::init::_$u7b$$u7b$closure$u7d$$u7d$::ha3c054e43f537b46 in libopenssl_sys-19a6b0094a10f644.rlib(openssl_sys-19a6b0094a10f644.openssl_sys.3vwedubj-cgu.9.rcgu.o)
            "_OPENSSL_add_all_algorithms_noconf", referenced from:
                openssl_sys::init::_$u7b$$u7b$closure$u7d$$u7d$::ha3c054e43f537b46 in libopenssl_sys-19a6b0094a10f644.rlib(openssl_sys-19a6b0094a10f644.openssl_sys.3vwedubj-cgu.9.rcgu.o)
            "_SSL_library_init", referenced from:
                openssl_sys::init::_$u7b$$u7b$closure$u7d$$u7d$::ha3c054e43f537b46 in libopenssl_sys-19a6b0094a10f644.rlib(openssl_sys-19a6b0094a10f644.openssl_sys.3vwedubj-cgu.9.rcgu.o)
            "_SSLeay", referenced from:
                openssl::version::number::hb0640a49a7a65ba1 in libopenssl-66169f4e5a0a9ec5.rlib(openssl-66169f4e5a0a9ec5.openssl.1o5pd6yu-cgu.15.rcgu.o)
          ld: symbol(s) not found for architecture x86_64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

What should I do?
OS: macOS 10.14

I delete the openssl 1.1 and it works now. thanks

@lelandjansen
Copy link
Contributor

Tip: In v2.0.0 the feature is called openssl.

# Cargo.toml
actix-web = { version = "2.0.0", features = ["openssl"] }

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

6 participants