Mitsuhiro Koga avatar Mitsuhiro Koga committed 3e59f9a

svnrepo: Support --insecure option the same as the mercurial

To bypass verification of ssl certificate on one of the following:
- Specify the --insecure option
- Set the fingerprint to config hostfingerprints

Comments (0)

Files changed (1)

hgsubversion/svnrepo.py

         password = self.ui.getpass('Passphrase for \'%s\': ' % (realm,), default='')
         return (password, bool(may_save))
 
+    def insecure(fn):
+        def fun(self, *args, **kwargs):
+            failures = args[1]
+            cert_info = args[2]
+            # cert_info[0] is hostname
+            # cert_info[1] is fingerprint
+
+            fingerprint = self.ui.config('hostfingerprints', cert_info[0])
+            if fingerprint and fingerprint.lower() == cert_info[1].lower():
+                # same as the acceptance temporarily
+                return (failures, False)
+
+            cacerts = self.ui.config('web', 'cacerts')
+            if not cacerts:
+                # same as the acceptance temporarily
+                return (failures, False)
+
+            return fn(self, *args, **kwargs)
+        return fun
+
+    @insecure
     def ssl_server_trust(self, realm, failures, cert_info, may_save, pool=None):
         msg = 'Error validating server certificate for \'%s\':\n' % (realm,)
         if failures & svnwrap.SSL_UNKNOWNCA:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.