C K Kashyap | 23 Feb 16:28 2013
Picon

Need urgent help with Network.tls

Hi,

I am trying to use Haskell to download email/attachments from gmail. For which I am exploring Network.TLS. I got this sample from the net that connects to gmail smtp and works just fine -

However, when I modify it a bit to try to connect to imap, it simply does not work. To debug, I tried to connect to a webserver, even that seems to not work. I modified the function as follows.


emailGmail2 = do
        let host = "localhost"
        let port = 443
let params = defaultParamsClient{pCiphers = ciphers}
g <- RNG.makeSystem
h <- connectTo host (PortNumber (fromIntegral port))
hSetBuffering h LineBuffering
cWrite h "GET / HTTP/1.0"
cWrite h ""
cWaitFor h "ABCD"
con <- contextNewOnHandle h params g
handshake con
bye con


And I get a "BAD request" response from the server - Can some please give me a sample code that uses Network.TLS to connect to a imap.google.com (or even a webserver for that matter)?

Regards,
Kashyap
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
satvik chauhan | 23 Feb 18:16 2013
Picon

Re: Need urgent help with Network.tls

You can use HaskellNet or imapget directly or look into their source code for connecting to imap manually. 


-Satvik

On Sat, Feb 23, 2013 at 8:58 PM, C K Kashyap <ckkashyap <at> gmail.com> wrote:
Hi,

I am trying to use Haskell to download email/attachments from gmail. For which I am exploring Network.TLS. I got this sample from the net that connects to gmail smtp and works just fine -

However, when I modify it a bit to try to connect to imap, it simply does not work. To debug, I tried to connect to a webserver, even that seems to not work. I modified the function as follows.


emailGmail2 = do
        let host = "localhost"
        let port = 443
let params = defaultParamsClient{pCiphers = ciphers}
g <- RNG.makeSystem
h <- connectTo host (PortNumber (fromIntegral port))
hSetBuffering h LineBuffering
cWrite h "GET / HTTP/1.0"
cWrite h ""
cWaitFor h "ABCD"
con <- contextNewOnHandle h params g
handshake con
bye con


And I get a "BAD request" response from the server - Can some please give me a sample code that uses Network.TLS to connect to a imap.google.com (or even a webserver for that matter)?

Regards,
Kashyap

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
C K Kashyap | 23 Feb 19:58 2013
Picon

Re: Need urgent help with Network.tls

The reason I want to use TLS is that I'd want to pack the whole thing in a DLL and give it off to a friend for use.

What I am really looking for is a small sample code that demonstrates how TLS package can be used to connect to a webserver or imapserver.

Regards,
Kashyap


On Sat, Feb 23, 2013 at 10:46 PM, satvik chauhan <mystic.satvik <at> gmail.com> wrote:
You can use HaskellNet or imapget directly or look into their source code for connecting to imap manually. 

-Satvik

On Sat, Feb 23, 2013 at 8:58 PM, C K Kashyap <ckkashyap <at> gmail.com> wrote:
Hi,

I am trying to use Haskell to download email/attachments from gmail. For which I am exploring Network.TLS. I got this sample from the net that connects to gmail smtp and works just fine -

However, when I modify it a bit to try to connect to imap, it simply does not work. To debug, I tried to connect to a webserver, even that seems to not work. I modified the function as follows.


emailGmail2 = do
        let host = "localhost"
        let port = 443
let params = defaultParamsClient{pCiphers = ciphers}
g <- RNG.makeSystem
h <- connectTo host (PortNumber (fromIntegral port))
hSetBuffering h LineBuffering
cWrite h "GET / HTTP/1.0"
cWrite h ""
cWaitFor h "ABCD"
con <- contextNewOnHandle h params g
handshake con
bye con


And I get a "BAD request" response from the server - Can some please give me a sample code that uses Network.TLS to connect to a imap.google.com (or even a webserver for that matter)?

Regards,
Kashyap

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Brandon Allbery | 23 Feb 22:05 2013
Picon

Re: Need urgent help with Network.tls

On Sat, Feb 23, 2013 at 1:58 PM, C K Kashyap <ckkashyap <at> gmail.com> wrote:
What I am really looking for is a small sample code that demonstrates how TLS package can be used to connect to a webserver or imapserver.

TLS isn't actually SSL, despite SSL getting blessed as "TLS 0.9". Various attempts at TLS-enabled web protocols have foundered, so you won't find much code to speak TLS to web servers. (SSL is negotiated at socket connect time and involves no protocol commands.) In short, sample code that can do https would be completely useless for comparing to TLS-enabled code.

IMAP is somewhat harder than SMTP; I suggest you read up on the protocol. I've done a fair amount of work with it, and still would have to refer to the RFC to establish a connection without the help of an existing IMAP library.

--
brandon s allbery kf8nh                               sine nomine associates
allbery.b <at> gmail.com                                  ballbery <at> sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Vincent Hanquez | 23 Feb 23:28 2013

Re: Need urgent help with Network.tls

On 02/23/2013 09:05 PM, Brandon Allbery wrote:
> On Sat, Feb 23, 2013 at 1:58 PM, C K Kashyap <ckkashyap <at> gmail.com> wrote:
>
>> What I am really looking for is a small sample code that demonstrates how
>> TLS package can be used to connect to a webserver or imapserver.
>>
> TLS isn't actually SSL, despite SSL getting blessed as "TLS 0.9". Various
> attempts at TLS-enabled web protocols have foundered, so you won't find
> much code to speak TLS to web servers. (SSL is negotiated at socket connect
> time and involves no protocol commands.) In short, sample code that can do
> https would be completely useless for comparing to TLS-enabled code.

SSL and TLS can be negociated at socket connect. TLS is just the 
standard name of SSL. at the wire level, TLS1.x is SSL 3.(1+x).

What you're refering to is the STARTTLS style protocol command which 
work independently of the version of TLS (include SSL2, SSL3).

Many programs have abused "SSL" and "TLS" different name to 
differentiate how TLS is negociated (straight away, or with a protocol 
command). Fortunately more and more programs do the right thing and 
differentiate the two types with the following two options: "SSL/TLS" or 
"STARTTLS".

--

-- 
Vincent
Vincent Hanquez | 23 Feb 23:12 2013

Re: Need urgent help with Network.tls

On 02/23/2013 06:58 PM, C K Kashyap wrote:
> The reason I want to use TLS is that I'd want to pack the whole thing in a
> DLL and give it off to a friend for use.
>
> What I am really looking for is a small sample code that demonstrates how
> TLS package can be used to connect to a webserver or imapserver.
>
> Regards,
> Kashyap

Kashyap,

I suggest you look at the connection package [1] which is made for this 
specific purpose, and comes with examples on how to use it [2].

If you want to only use tls, i suggest to look at connection's code [3], 
or the tls-debug [4] package, which got many small utils that use tls.

[1] http://hackage.haskell.org/package/connection
[2] 
<https://github.com/vincenthz/hs-connection>https://github.com/vincenthz/hs-connection/tree/master/examples
[3] 
https://github.com/vincenthz/hs-connection/blob/master/Network/Connection.hs
[4] https://github.com/vincenthz/hs-tls/tree/master/debug/src

--

-- 
Vincent
C K Kashyap | 24 Feb 04:28 2013
Picon

Re: Need urgent help with Network.tls

Thank you so much Vincent,

I think this is what I need ... I tried to use it to connect to a local web server running in 443 - http://hpaste.org/82943 however, I get the following error - 

ssl_client.hs: connect: failed (Connection refused (WSAECONNREFUSED))

Am I missing something?

Regards,
Kashyap


On Sun, Feb 24, 2013 at 3:42 AM, Vincent Hanquez <tab <at> snarc.org> wrote:
On 02/23/2013 06:58 PM, C K Kashyap wrote:
The reason I want to use TLS is that I'd want to pack the whole thing in a
DLL and give it off to a friend for use.

What I am really looking for is a small sample code that demonstrates how
TLS package can be used to connect to a webserver or imapserver.

Regards,
Kashyap

Kashyap,

I suggest you look at the connection package [1] which is made for this specific purpose, and comes with examples on how to use it [2].

If you want to only use tls, i suggest to look at connection's code [3], or the tls-debug [4] package, which got many small utils that use tls.

[1] http://hackage.haskell.org/package/connection
[2] <https://github.com/vincenthz/hs-connection>https://github.com/vincenthz/hs-connection/tree/master/examples
[3] https://github.com/vincenthz/hs-connection/blob/master/Network/Connection.hs
[4] https://github.com/vincenthz/hs-tls/tree/master/debug/src

--
Vincent

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
C K Kashyap | 24 Feb 05:33 2013
Picon

Re: Need urgent help with Network.tls

Okay ... looks like connection is exactly what I want .... The examples work just fine on Linux .. however, on Windows, I continue to get the WSACONNECTIONREFUSED eror.

Even adding a "withSocketsDo" does not seem to help.

Regards,
Kashyap


On Sun, Feb 24, 2013 at 8:58 AM, C K Kashyap <ckkashyap <at> gmail.com> wrote:
Thank you so much Vincent,

I think this is what I need ... I tried to use it to connect to a local web server running in 443 - http://hpaste.org/82943 however, I get the following error - 

ssl_client.hs: connect: failed (Connection refused (WSAECONNREFUSED))

Am I missing something?

Regards,
Kashyap


On Sun, Feb 24, 2013 at 3:42 AM, Vincent Hanquez <tab <at> snarc.org> wrote:
On 02/23/2013 06:58 PM, C K Kashyap wrote:
The reason I want to use TLS is that I'd want to pack the whole thing in a
DLL and give it off to a friend for use.

What I am really looking for is a small sample code that demonstrates how
TLS package can be used to connect to a webserver or imapserver.

Regards,
Kashyap

Kashyap,

I suggest you look at the connection package [1] which is made for this specific purpose, and comes with examples on how to use it [2].

If you want to only use tls, i suggest to look at connection's code [3], or the tls-debug [4] package, which got many small utils that use tls.

[1] http://hackage.haskell.org/package/connection
[2] <https://github.com/vincenthz/hs-connection>https://github.com/vincenthz/hs-connection/tree/master/examples
[3] https://github.com/vincenthz/hs-connection/blob/master/Network/Connection.hs
[4] https://github.com/vincenthz/hs-tls/tree/master/debug/src

--
Vincent


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
C K Kashyap | 24 Feb 05:39 2013
Picon

Re: Need urgent help with Network.tls

Okay ... now magically, I stopped seeing the "WSACONNECTIONREFUSED" error!!! .. 

Regards,
Kashyap


On Sun, Feb 24, 2013 at 10:03 AM, C K Kashyap <ckkashyap <at> gmail.com> wrote:
Okay ... looks like connection is exactly what I want .... The examples work just fine on Linux .. however, on Windows, I continue to get the WSACONNECTIONREFUSED eror.

Even adding a "withSocketsDo" does not seem to help.

Regards,
Kashyap


On Sun, Feb 24, 2013 at 8:58 AM, C K Kashyap <ckkashyap <at> gmail.com> wrote:
Thank you so much Vincent,

I think this is what I need ... I tried to use it to connect to a local web server running in 443 - http://hpaste.org/82943 however, I get the following error - 

ssl_client.hs: connect: failed (Connection refused (WSAECONNREFUSED))

Am I missing something?

Regards,
Kashyap


On Sun, Feb 24, 2013 at 3:42 AM, Vincent Hanquez <tab <at> snarc.org> wrote:
On 02/23/2013 06:58 PM, C K Kashyap wrote:
The reason I want to use TLS is that I'd want to pack the whole thing in a
DLL and give it off to a friend for use.

What I am really looking for is a small sample code that demonstrates how
TLS package can be used to connect to a webserver or imapserver.

Regards,
Kashyap

Kashyap,

I suggest you look at the connection package [1] which is made for this specific purpose, and comes with examples on how to use it [2].

If you want to only use tls, i suggest to look at connection's code [3], or the tls-debug [4] package, which got many small utils that use tls.

[1] http://hackage.haskell.org/package/connection
[2] <https://github.com/vincenthz/hs-connection>https://github.com/vincenthz/hs-connection/tree/master/examples
[3] https://github.com/vincenthz/hs-connection/blob/master/Network/Connection.hs
[4] https://github.com/vincenthz/hs-tls/tree/master/debug/src

--
Vincent



_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Jason Dusek | 23 Feb 23:24 2013
Picon

Re: Need urgent help with Network.tls

2013/2/23 C K Kashyap <ckkashyap <at> gmail.com>:
> The reason I want to use TLS is that I'd want to pack the whole thing in a
> DLL and give it off to a friend for use.

Why does this requirement compel you to forego the imapget or HaskellNet
packages?

--
Jason Dusek
pgp // solidsnack // C1EBC57DC55144F35460C8DF1FD4C6C1FED18A2B
C K Kashyap | 24 Feb 04:23 2013
Picon

Re: Need urgent help with Network.tls

What I am looking to achieve is - create a DLL that would do the complete gmail thing that could be linked to a standard C program (on windows) and could be used to download emails from gmail.
What I gathered from HsOpenSSL (which is required for HaskellNet) depends on some native ssl dll .... That is the reason I wanted to get a standalone library ... again, I might have got the whole thing wrong.

Regards,
Kashyap


On Sun, Feb 24, 2013 at 3:54 AM, Jason Dusek <jason.dusek <at> gmail.com> wrote:
2013/2/23 C K Kashyap <ckkashyap <at> gmail.com>:
> The reason I want to use TLS is that I'd want to pack the whole thing in a
> DLL and give it off to a friend for use.

Why does this requirement compel you to forego the imapget or HaskellNet
packages?

--
Jason Dusek
pgp // solidsnack // C1EBC57DC55144F35460C8DF1FD4C6C1FED18A2B

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Vincent Hanquez | 23 Feb 23:35 2013

Re: Need urgent help with Network.tls

On 02/23/2013 03:28 PM, C K Kashyap wrote:
> Hi,
>
> I am trying to use Haskell to download email/attachments from gmail. For
> which I am exploring Network.TLS. I got this sample from the net that
> connects to gmail smtp and works just fine -
> http://hpaste.org/82890
Your example look odd,

Typically you would either:

* connect directly using tls (usually using the standard "secure" 
service port)
* or connect to the normal service port, do a basic handshake with the 
server, tell that you're going to switch the connection with STARTTLS, 
and use tls.

but you will not use both methods in the same connection.

Hope that helps,
--

-- 
Vincent

Gmane