How do I create a connection with the equivalent of `-starttls smtp` using rust-openssl?
When I run the following command in the terminal
openssl s_client -connect gmail-smtp-in.l.google.com:25 -starttls smtp
I get a CONNECTED(00000005) response.
I am trying to achieve the same connection with Rust using rust-openssl (I am open to other libraries though), and here's what I have:
extern crate openssl;
use openssl::ssl::SslConnector, SslMethod;
use std::net::TcpStream;
fn main()
let connector = SslConnector::builder(SslMethod::tls()).unwrap().build();
let stream = TcpStream::connect("gmail-smtp-in.l.google.com:25").unwrap();
let e = connector
.connect("gmail-smtp-in.l.google.com", stream)
.unwrap_err();
eprintln!(":#?", e);
However, the response I get is:
Failure(
MidHandshakeSslStream
stream: SslStream
stream: TcpStream
addr: V6(
[2001:41d0:a:2346::1]:57190
),
peer: V6(
[2a00:1450:400c:c0c::1b]:25
),
fd: 3
,
ssl: Ssl
state: "SSLv3/TLS write client hello",
verify_result: X509VerifyResult
code: 0,
error: "ok"
,
error: Error
code: ErrorCode(
1
),
cause: Some(
Ssl(
ErrorStack(
[
Error
code: 336130315,
library: "SSL routines",
function: "ssl3_get_record",
reason: "wrong version number",
file: "ssl/record/ssl3_record.c",
line: 252
]
)
)
)
)
I'm guessing I'm missing the -starttls smtp part in the Rust code, but can't figure out how to add it.
openssl rust smtp starttls
add a comment |
When I run the following command in the terminal
openssl s_client -connect gmail-smtp-in.l.google.com:25 -starttls smtp
I get a CONNECTED(00000005) response.
I am trying to achieve the same connection with Rust using rust-openssl (I am open to other libraries though), and here's what I have:
extern crate openssl;
use openssl::ssl::SslConnector, SslMethod;
use std::net::TcpStream;
fn main()
let connector = SslConnector::builder(SslMethod::tls()).unwrap().build();
let stream = TcpStream::connect("gmail-smtp-in.l.google.com:25").unwrap();
let e = connector
.connect("gmail-smtp-in.l.google.com", stream)
.unwrap_err();
eprintln!(":#?", e);
However, the response I get is:
Failure(
MidHandshakeSslStream
stream: SslStream
stream: TcpStream
addr: V6(
[2001:41d0:a:2346::1]:57190
),
peer: V6(
[2a00:1450:400c:c0c::1b]:25
),
fd: 3
,
ssl: Ssl
state: "SSLv3/TLS write client hello",
verify_result: X509VerifyResult
code: 0,
error: "ok"
,
error: Error
code: ErrorCode(
1
),
cause: Some(
Ssl(
ErrorStack(
[
Error
code: 336130315,
library: "SSL routines",
function: "ssl3_get_record",
reason: "wrong version number",
file: "ssl/record/ssl3_record.c",
line: 252
]
)
)
)
)
I'm guessing I'm missing the -starttls smtp part in the Rust code, but can't figure out how to add it.
openssl rust smtp starttls
I think you should open an issue, they could help you more than us.
– Stargateur
Nov 12 '18 at 20:21
add a comment |
When I run the following command in the terminal
openssl s_client -connect gmail-smtp-in.l.google.com:25 -starttls smtp
I get a CONNECTED(00000005) response.
I am trying to achieve the same connection with Rust using rust-openssl (I am open to other libraries though), and here's what I have:
extern crate openssl;
use openssl::ssl::SslConnector, SslMethod;
use std::net::TcpStream;
fn main()
let connector = SslConnector::builder(SslMethod::tls()).unwrap().build();
let stream = TcpStream::connect("gmail-smtp-in.l.google.com:25").unwrap();
let e = connector
.connect("gmail-smtp-in.l.google.com", stream)
.unwrap_err();
eprintln!(":#?", e);
However, the response I get is:
Failure(
MidHandshakeSslStream
stream: SslStream
stream: TcpStream
addr: V6(
[2001:41d0:a:2346::1]:57190
),
peer: V6(
[2a00:1450:400c:c0c::1b]:25
),
fd: 3
,
ssl: Ssl
state: "SSLv3/TLS write client hello",
verify_result: X509VerifyResult
code: 0,
error: "ok"
,
error: Error
code: ErrorCode(
1
),
cause: Some(
Ssl(
ErrorStack(
[
Error
code: 336130315,
library: "SSL routines",
function: "ssl3_get_record",
reason: "wrong version number",
file: "ssl/record/ssl3_record.c",
line: 252
]
)
)
)
)
I'm guessing I'm missing the -starttls smtp part in the Rust code, but can't figure out how to add it.
openssl rust smtp starttls
When I run the following command in the terminal
openssl s_client -connect gmail-smtp-in.l.google.com:25 -starttls smtp
I get a CONNECTED(00000005) response.
I am trying to achieve the same connection with Rust using rust-openssl (I am open to other libraries though), and here's what I have:
extern crate openssl;
use openssl::ssl::SslConnector, SslMethod;
use std::net::TcpStream;
fn main()
let connector = SslConnector::builder(SslMethod::tls()).unwrap().build();
let stream = TcpStream::connect("gmail-smtp-in.l.google.com:25").unwrap();
let e = connector
.connect("gmail-smtp-in.l.google.com", stream)
.unwrap_err();
eprintln!(":#?", e);
However, the response I get is:
Failure(
MidHandshakeSslStream
stream: SslStream
stream: TcpStream
addr: V6(
[2001:41d0:a:2346::1]:57190
),
peer: V6(
[2a00:1450:400c:c0c::1b]:25
),
fd: 3
,
ssl: Ssl
state: "SSLv3/TLS write client hello",
verify_result: X509VerifyResult
code: 0,
error: "ok"
,
error: Error
code: ErrorCode(
1
),
cause: Some(
Ssl(
ErrorStack(
[
Error
code: 336130315,
library: "SSL routines",
function: "ssl3_get_record",
reason: "wrong version number",
file: "ssl/record/ssl3_record.c",
line: 252
]
)
)
)
)
I'm guessing I'm missing the -starttls smtp part in the Rust code, but can't figure out how to add it.
openssl rust smtp starttls
openssl rust smtp starttls
edited Nov 15 '18 at 15:25
Shepmaster
151k13292431
151k13292431
asked Nov 12 '18 at 16:42
amaurymartinyamaurymartiny
1,84811744
1,84811744
I think you should open an issue, they could help you more than us.
– Stargateur
Nov 12 '18 at 20:21
add a comment |
I think you should open an issue, they could help you more than us.
– Stargateur
Nov 12 '18 at 20:21
I think you should open an issue, they could help you more than us.
– Stargateur
Nov 12 '18 at 20:21
I think you should open an issue, they could help you more than us.
– Stargateur
Nov 12 '18 at 20:21
add a comment |
1 Answer
1
active
oldest
votes
Take a more detailed look in the openssl-sources on what -starttls smtp actually does, and replay that in Rust? It will just be a few library calls, but first you need to speak STMP to your server, and then switch to TLS. (Maybe that's already bundled up in the openssl-library in a single call.)
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53266542%2fhow-do-i-create-a-connection-with-the-equivalent-of-starttls-smtp-using-rust%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Take a more detailed look in the openssl-sources on what -starttls smtp actually does, and replay that in Rust? It will just be a few library calls, but first you need to speak STMP to your server, and then switch to TLS. (Maybe that's already bundled up in the openssl-library in a single call.)
add a comment |
Take a more detailed look in the openssl-sources on what -starttls smtp actually does, and replay that in Rust? It will just be a few library calls, but first you need to speak STMP to your server, and then switch to TLS. (Maybe that's already bundled up in the openssl-library in a single call.)
add a comment |
Take a more detailed look in the openssl-sources on what -starttls smtp actually does, and replay that in Rust? It will just be a few library calls, but first you need to speak STMP to your server, and then switch to TLS. (Maybe that's already bundled up in the openssl-library in a single call.)
Take a more detailed look in the openssl-sources on what -starttls smtp actually does, and replay that in Rust? It will just be a few library calls, but first you need to speak STMP to your server, and then switch to TLS. (Maybe that's already bundled up in the openssl-library in a single call.)
answered Nov 15 '18 at 16:00
ShiDoiSiShiDoiSi
6,2392343
6,2392343
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53266542%2fhow-do-i-create-a-connection-with-the-equivalent-of-starttls-smtp-using-rust%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I think you should open an issue, they could help you more than us.
– Stargateur
Nov 12 '18 at 20:21