Skip to content

Commit

Permalink
Update ssl
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Bentley committed Apr 5, 2017
1 parent 2538438 commit c8cb5dc
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 12 deletions.
127 changes: 122 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = ["Matthew Bentley <[email protected]>"]
nickel = "*"
rustc-serialize = "*"
hyper = "*"
hyper-openssl = "*"
hyper-native-tls = "*"
modifier = "*"
postgres = "*"
r2d2_postgres = "*"
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ MAINTAINER Matthew Bentley "[email protected]"

ENV USER "Matthew Bentley"

RUN apt update && apt install -y libssl-dev
RUN apt update && apt install -y libssl-dev openssl

RUN mkdir /hackcwru/
ADD . /hackcwru/
Expand Down
14 changes: 9 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
extern crate nickel;
extern crate rustc_serialize;
extern crate hyper;
extern crate hyper_openssl;
extern crate hyper_native_tls;
extern crate nickel_postgres;
extern crate postgres;
extern crate r2d2_postgres;
Expand All @@ -20,7 +20,7 @@ use hyper::net::HttpsConnector;
use hyper::header::{Connection, Authorization, Basic};
use hyper::status::StatusClass;
use hyper::client::response::Response;
use hyper_openssl::OpensslClient;
use hyper_native_tls::NativeTlsClient;
use std::io::Read;
use std::env;
use r2d2::{NopErrorHandler, PooledConnection};
Expand Down Expand Up @@ -163,7 +163,7 @@ fn check_http_error(res: &Response) -> Result<(), ApiError> {
// TODO: Something better about the long api urls
fn do_request(code: &str) -> Result<Data, RequestError> {
let id = env_err!("ID");
let ssl = OpensslClient::new().unwrap();
let ssl = NativeTlsClient::new().unwrap();
let connector = HttpsConnector::new(ssl);
let client = Client::with_connector(connector);
let secret = env_err!("SECRET");
Expand Down Expand Up @@ -207,7 +207,9 @@ fn do_request(code: &str) -> Result<Data, RequestError> {
// Send a message to slack when a new user signs up
fn slack_send(user: &User) -> Result<(), RequestError> {
let url = env_err!("SLACKURL");
let client = Client::new();
let ssl = NativeTlsClient::new().unwrap();
let connector = HttpsConnector::new(ssl);
let client = Client::with_connector(connector);
let payload = Payload {
channel: "#signups".to_string(),
username: "Signup bot".to_string(),
Expand Down Expand Up @@ -235,7 +237,9 @@ fn mailchimp_add(user: User) -> Result<(), RequestError> {
username: "foobar".to_owned(),
password: Some(auth),
});
let client = Client::new();
let ssl = NativeTlsClient::new().unwrap();
let connector = HttpsConnector::new(ssl);
let client = Client::with_connector(connector);
let mailchimpdata = MailChimpData::from(user);
let mailchimpdata_str = try!(json::encode(&mailchimpdata));
let res = try!(client.post(&url)
Expand Down

0 comments on commit c8cb5dc

Please sign in to comment.