Skip to contentSkip to conversation

git-imap-send: Add support for SSL.

PATCH In review Robert Shearman 5 participants 8 messages Jun 15, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/4 git-imap-send: Add support for SSL.

Allow SSL to be used when a imaps:// URL is used for the host name.

Also, automatically use TLS when not using imaps:// by using the IMAP STARTTLS command, if the server supports it.

Tested with Courier and Gimap IMAP servers.

---
 Documentation/git-imap-send.txt |    5 +-
 Makefile                        |    4 +-
 imap-send.c                     |  166 +++++++++++++++++++++++++++++++++++----
 3 files changed, 157 insertions(+), 18 deletions(-)
Documentation/git-imap-send.txt +3 -2
index b3d8da3..e4a5873 100644
@@ -37,10 +37,11 @@ configuration file (shown with examples):
     Tunnel = "ssh -q [email protected] /usr/bin/imapd ./Maildir 2> /dev/null"
 
 [imap]
-    Host = imap.server.com
+    Host = imaps://imap.example.com
     User = bob
     Pass = pwd
-    Port = 143
+    Port = 993
+    sslverify = false
 ..........................
 
 
Makefile +3 -1
index bddd1a7..d9265f7 100644
@@ -1193,7 +1193,9 @@ endif
 git-%$X: %.o $(GITLIBS)
 	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
 
-git-imap-send$X: imap-send.o $(LIB_FILE)
+git-imap-send$X: imap-send.o $(GITLIBS)
+	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
+		$(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL)
 
 http.o http-walker.o http-push.o transport.o: http.h
 
imap-send.c +151 -15

279 lines not on this page · raw message

Signature · 1 line
1.5.6.GIT
#1 lore raw
Quoted 5 lines · Robert Shearman

Allow SSL to be used when a imaps:// URL is used for the host name.

Also, automatically use TLS when not using imaps:// by using the IMAP STARTTLS command, if the server supports it.

Tested with Courier and Gimap IMAP servers.

Sign-off?

Quoted 6 lines
Documentation/git-imap-send.txt +0 -0
index b3d8da3..e4a5873 100644
@@ -37,10 +37,11 @@ configuration file (shown with examples):
     Tunnel = "ssh -q [email protected] /usr/bin/imapd ./Maildir 2> /dev/null"

Documentation/git-imap-send.txt configuration file (shown with examples): · line 44

Quoted 10 lines
Documentation/git-imap-send.txt +3 -2
 
 [imap]
-    Host = imap.server.com
+    Host = imaps://imap.example.com
     User = bob
     Pass = pwd
-    Port = 143
+    Port = 993
+    sslverify = false
..........................

Don't we also want to keep a vanilla configuration in the example, or is imaps the norm and unencrypted imap is exception these days?

Don't we need to support custom certificates, keys and CAs, just like our code that supports https does, by honoring GIT_SSL_* environment variables and configuration file entries? The patch itself looks fairly clean, and I'd like to queue this for wider testing, initially even without GIT_SSL_* support. But I'd like to see any patch with substantial amount of changes properly signed off.

Thanks.

#2 lore raw

2008/7/9 Junio C Hamano <[email protected]>:

Quoted 8 lines
Quoted 7 lines · Robert Shearman
Documentation/git-imap-send.txt +0 -0
index b3d8da3..e4a5873 100644
@@ -37,10 +37,11 @@ configuration file (shown with examples):
     Tunnel = "ssh -q [email protected] /usr/bin/imapd ./Maildir 2> /dev/null"
 
Quoted 12 lines

Documentation/git-imap-send.txt configuration file (shown with examples): · line 44

Quoted 9 lines
Documentation/git-imap-send.txt +3 -2
 [imap]
-    Host = imap.server.com
+    Host = imaps://imap.example.com
     User = bob
     Pass = pwd
-    Port = 143
+    Port = 993
+    sslverify = false
..........................

Don't we also want to keep a vanilla configuration in the example, or is imaps the norm and unencrypted imap is exception these days?

Good point. I'll fix the documentation to use imap:// instead of imaps:// and not change the port number. However, I'm not sure the examples should be telling the user what they should do, but rather what they can do.

Quoted 3 lines

Don't we need to support custom certificates, keys and CAs, just like our code that supports https does, by honoring GIT_SSL_* environment variables and configuration file entries?

Yes, eventually we will want that support in imap-send too. It should be fairly trivial to do, although testing will be more difficult.

Quoted 4 lines

The patch itself looks fairly clean, and
I'd like to queue this for wider testing, initially even without GIT_SSL_* support. But I'd like to see any patch with substantial amount of changes properly signed off.

Great. I'll resend the series later with changes from the comments I've received and properly signed-off.

Signature · 1 line
Rob Shearman
#3 lore raw
Quoted 9 lines · Rob Shearman

2008/7/9 Junio C Hamano <[email protected]>:
...

Quoted 2 lines

Don't we also want to keep a vanilla configuration in the example, or is imaps the norm and unencrypted imap is exception these days?

Good point. I'll fix the documentation to use imap:// instead of imaps:// and not change the port number. However, I'm not sure the examples should be telling the user what they should do, but rather what they can do.

My comment was purely about losing the basic example by replacing it with something more advanced. Nobody prevents you from having _more_ examples. "You can do this, you can do that, also here is an example of how to use SSL".

#4 lore raw
In reply to Junio C Hamano
Quoted 8 lines · At 2008-07-08 16:20:19 -0700, [email protected] wrote:

Documentation/git-imap-send.txt configuration file (shown with examples): · line 44

Quoted 5 lines
Documentation/git-imap-send.txt +2 -1
-    Port = 143
+    Port = 993
+    sslverify = false
..........................

Don't we also want to keep a vanilla configuration in the example, or is imaps the norm and unencrypted imap is exception these days?

The norm is IMAP+STARTTLS on port 143, not IMAPS on port 993. The latter is also widely deployed for compatibility with older clients, but it is non-standard and its use isn't exactly encouraged.

-- ams

#5 lore raw
In reply to Robert Shearman
Quoted 13 lines · Robert Shearman
Documentation/git-imap-send.txt +3 -2
@@ -37,10 +37,11 @@ configuration file (shown with examples):
     Tunnel = "ssh -q [email protected] /usr/bin/imapd ./Maildir 2> /dev/null"
 
 [imap]
-    Host = imap.server.com
+    Host = imaps://imap.example.com
     User = bob
     Pass = pwd
-    Port = 143
+    Port = 993
+    sslverify = false

[...]

Documentation/git-imap-send.txt git_imap_config(const char *key, const char *val, void *cb) · line 1415

Quoted 6 lines
Documentation/git-imap-send.txt +2 -0
@@ -1280,6 +1411,8 @@ git_imap_config(const char *key, const char *val, void *cb)
 		server.port = git_config_int( key, val );
 	else if (!strcmp( "tunnel", key ))
 		server.tunnel = xstrdup( val );
+	else if (!strcmp( "ssl_verify", key ))
+		server.ssl_verify = git_config_bool( key, val );

The example and the code disagree on the name of the sslverify/ssl_verify option. Also, ssl_verify needs explanation.

- Josh Triplett

#6 lore raw

2008/7/9 Josh Triplett <[email protected]>:

Quoted 15 lines · Robert Shearman
Quoted 13 lines
Documentation/git-imap-send.txt +3 -2
@@ -37,10 +37,11 @@ configuration file (shown with examples):
     Tunnel = "ssh -q [email protected] /usr/bin/imapd ./Maildir 2> /dev/null"
 
 [imap]
-    Host = imap.server.com
+    Host = imaps://imap.example.com
     User = bob
     Pass = pwd
-    Port = 143
+    Port = 993
+    sslverify = false

[...]

Quoted 9 lines

Documentation/git-imap-send.txt git_imap_config(const char *key, const char *val, void *cb) · line 1415

Quoted 6 lines
Documentation/git-imap-send.txt +2 -0
@@ -1280,6 +1411,8 @@ git_imap_config(const char *key, const char *val, void *cb)
              server.port = git_config_int( key, val );
      else if (!strcmp( "tunnel", key ))
              server.tunnel = xstrdup( val );
+     else if (!strcmp( "ssl_verify", key ))
+             server.ssl_verify = git_config_bool( key, val );

The example and the code disagree on the name of the sslverify/ssl_verify option.

I wouldn't exactly call it "disagree". The config variable is limited by not allowing underscores, whereas the C language does allow them.

Quoted 1 line

Also, ssl_verify needs explanation.

See patch 4/4.

Signature · 1 line
Rob Shearman
#7 lore raw
Quoted 10 lines · Rob Shearman
Quoted 7 lines
Quoted 2 lines

[imap]
+ sslverify = false

[...]

Quoted 1 line

+ else if (!strcmp( "ssl_verify", key ))

The example and the code disagree on the name of the sslverify/ssl_verify option.

I wouldn't exactly call it "disagree". The config variable is limited by not allowing underscores, whereas the C language does allow them.

I think his point is that the example says "sslverify" but the code is looking for the config variable "ssl_verify". So that config won't work.

However as you mention, underscore isn't allowed, so your strcmp line is totally bogus anyway, but you silently fix it in your 3/4 "style" fix.

-Peff