Debugging Exchange IMAP sessions with openssl s_client

I was just curious about the fact that openssl s_client -connect exchangeserver:993 was not working the way I expected it to work. I saw the greeting of the server but wasn’t able to do send any commands such as A1 CAPABILITY. The same worked for all other servers in the past.

Interestingly enough telnet exchangeserver 143 worked, but for obvious reasons unencrypted connections are not an option.

The reason behind is that in fact IMAP and telnet protocol and uses CRLF as line endings and Exchange servers are a bit picky on this specific point. As openssl is not a native client like telnet it sends whatever the terminal uses.

However there is already an solution builtin openssl s_client. Just pass the additional crlf option:

$ openssl s_client -connect exchangeserver:993 -crlf

Show http header / file information without actually downloading

To show the http meta information such as modification date or file size without downloading actually the data you can use the following commands:

$ HEAD http://www.georglutz.de/blog
200 OK
Cache-Control: no-cache, pre-check=0, post-check=0
Connection: close
Date: Sat, 05 Sep 2009 18:12:30 GMT
Pragma: no-cache
ETag: "Sat, 05 Sep 2009 09:11:22 GMT"
Server: Apache/2.0.52 (CentOS)
Content-Type: text/xml; charset=utf-8
Expires: 0
Last-Modified: Sat, 05 Sep 2009 09:11:22 GMT
Client-Date: Sat, 05 Sep 2009 18:12:31 GMT
Client-Peer: 85.214.18.185:80
Client-Response-Num: 1
Set-Cookie: PHPSESSID=xyz; path=/
Set-Cookie: PHPSESSID=abc; path=/
Status: 200 OK
X-Blog: Serendipity
X-Powered-By: PHP/4.3.9
X-Serendipity-InterfaceLang: de
X-Serendipity-InterfaceLangSource: Content-Negotiation
X-Session-Reinit: true

$ wget -S --spider http://www.georglutz.de/blog/feeds/index.rss
Spider-Modus eingeschaltet.  Prüfe ob die Datei auf dem Server existiert.
--2009-09-05 20:13:38--  http://www.georglutz.de/blog/feeds/index.rss
Auflösen des Hostnamen »www.georglutz.de«.... 85.214.18.185, 2002:55d6:12b9::1
Verbindungsaufbau zu www.georglutz.de|85.214.18.185|:80... verbunden.
HTTP Anforderung gesendet, warte auf Antwort...
  HTTP/1.1 200 OK
  Date: Sat, 05 Sep 2009 18:13:38 GMT
  Server: Apache/2.0.52 (CentOS)
  X-Powered-By: PHP/4.3.9
  Status: 200 OK
  Set-Cookie: PHPSESSID=xyz; path=/
  Expires: 0
  Cache-Control: no-cache, pre-check=0, post-check=0
  Pragma: no-cache
  Set-Cookie: PHPSESSID=abc; path=/
  X-Session-Reinit: true
  X-Serendipity-InterfaceLangSource: Content-Negotiation
  X-Serendipity-InterfaceLang: de
  X-Blog: Serendipity
  Last-Modified: Sat, 05 Sep 2009 09:11:22 GMT
  ETag: "Sat, 05 Sep 2009 09:11:22 GMT"
  Connection: close
  Content-Type: text/xml; charset=utf-8
Länge: nicht spezifiziert [text/xml]
Datei auf dem Server existiert.

In Fedora 10 HEAD is part of the package perl-libwww-perl.

Use terminal scrollback buffer in screen sessions

Its quite annoying that in screens default settings you cannot scroll back in history like you used to with shift-pageup/shift-pagedown,

In order to be able to use the local scroll history of your terminal add this to your ~/.screenrc

termcapinfo xterm|xterms|xs ti=\E7\E[?47l