Mercurial > hg-stable
comparison hgext/patchbomb.py @ 18888:19d489404d79
smtp: verify the certificate of the SMTP server for STARTTLS/SMTPS
Before this patch, the certificate of the SMTP server for STARTTLS or
SMTPS isn't verified.
This may cause man-in-the-middle security problem (stealing
authentication information), even though SMTP channel itself is
encrypted by SSL.
When "[smtp] tls" is configured as "smtps" or "starttls", this patch:
- uses classes introduced by preceding patches instead of "SMTP" or
"SMTP_SSL" of smtplib, and
- verifies the certificate of the SMTP server, if "[smtp]
verifycert" is configured as other than False
"[smtp] verifycert" can be configured in 3 levels:
- "strict":
This verifies peer certificate, and aborts if:
- peer certification is not valid, or
- no configuration in "[hostfingerprints]" and "[web] cacerts"
This is default value of "[smtp] verifycert" for security.
- "loose":
This verifies peer certificate, and aborts if peer certification is
not valid.
This just shows warning message ("certificate not verified"), if
there is no configuration in "[hostfingerprints]" and "[web]
cacerts".
This is as same as verification for HTTPS connection.
- False(no verification):
Peer certificate is not verified.
This is as same as the behavior before this patch series.
"hg email --insecure" uses "loose" level, and ignores "[web] cacerts"
as same as push/pull/etc... with --insecure.
Ignoring "[web] cacerts" configuration for "hg email --insecure" is
already done in "dispatch._dispatch()" by looking "insecure" up in the
table of command options.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Tue, 26 Mar 2013 02:28:10 +0900 |
parents | a08775ec89f2 |
children | c58b6ab4c26f |
comparison
equal
deleted
inserted
replaced
18887:2d7fac049d3a | 18888:19d489404d79 |
---|---|
538 raise | 538 raise |
539 if fp is not ui: | 539 if fp is not ui: |
540 fp.close() | 540 fp.close() |
541 else: | 541 else: |
542 if not sendmail: | 542 if not sendmail: |
543 sendmail = mail.connect(ui, mbox=mbox) | 543 verifycert = ui.config('smtp', 'verifycert') |
544 if opts.get('insecure'): | |
545 ui.setconfig('smtp', 'verifycert', 'loose') | |
546 try: | |
547 sendmail = mail.connect(ui, mbox=mbox) | |
548 finally: | |
549 ui.setconfig('smtp', 'verifycert', verifycert) | |
544 ui.status(_('sending '), subj, ' ...\n') | 550 ui.status(_('sending '), subj, ' ...\n') |
545 ui.progress(_('sending'), i, item=subj, total=len(msgs)) | 551 ui.progress(_('sending'), i, item=subj, total=len(msgs)) |
546 if not mbox: | 552 if not mbox: |
547 # Exim does not remove the Bcc field | 553 # Exim does not remove the Bcc field |
548 del m['Bcc'] | 554 del m['Bcc'] |