Repository: conan-io/conan

Issue:
scm.verify_ssl doesn't work for git clone
Conan version, operating system version and any tool that can be relevant.
```
$ conan --version
Conan version 1.16.1
$ uname -a
Linux centos 3.10.0-957.10.1.el7.x86_64 #1 SMP Mon Mar 18 15:06:45 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
$ git --version
git version 2.16.5
```

**Steps to reproduce:**
1. conanfile.py: add `scm` attribute with verify_ssl=False and url with https://local_git_repo that has local ssl certificate (not signed by root certificate)
2. Try to build such package, e.g. with --build=missing

**Example:**
```
   scm = {'type': 'git', 'url': 'https://local_git_repo', 'revision': 'auto', 'verify_ssl': False}
```

**Expected behavior:**
Conan is able to clone repo with sources and build it.

**Actual behavior:**
```
ERROR: Command 'git clone "https://local_git_repo" .  ' returned non-zero exit status 128.
```

**Conan 1.12.3 gave more details:**
```
cloning into '.'...
fatal: unable to access 'https://local_git_repo': The certificate issuer's certificate has expired.  Check your system date and time.
ERROR: Command 'git clone "https://local_git_repo" .  ' returned non-zero exit status 128.
```

I see two problems:
1. verify_ssl is removed during `conan export`
Example of exported scm attribute:
```
    scm = {"revision": "cb8a328e7543e1b3c701bec1a8832036a6bd144b",
           "type": "git",
           "url": "https://local_git_repo"}
```
2. `git config http.sslVerify false` is set *after* `git clone` in [conans/client/tools/scm.py](https://github.com/conan-io/conan/blob/67fb2dfd36e00910b903f64f498829cc8e9e7d9c/conans/client/tools/scm.py#L106)  so it doesn't affect `git clone` itself

Examples of running `git clone` itself:
```
$ git clone "https://local_git_repo"
Cloning into 'local_git_repo'...
fatal: unable to access 'https://local_git_repo': The certificate issuer's certificate has expired.  Check your system date and time.

$ git -c http.sslVerify=false clone "https://local_git_repo"
Cloning into 'local_git_repo'...
remote: Enumerating objects: 43, done.
remote: Counting objects: 100% (43/43), done.
remote: Compressing objects: 100% (24/24), done.
remote: Total 43 (delta 14), reused 43 (delta 14)
Unpacking objects: 100% (43/43), done.
```


Discussion:
Hi @Radrik5 and thanks for your detailed report.

I haven't tried to reproduce the case but I can see in the codebase the issue related to the verify command being done right after the clone.

On the other hand, I am not sure if there is any reason for removing the ``verify_ssl`` field in the SCM after the export. I think this is probably a bug too.

Also, I see the message from Conan 1.12.3 way more helpful than the current one, so we will have to investigate why this changed.

Thanks again for reporting
I was able to reproduce this issue and it has been tagged as a bug. Will try to work on a solution for next release. Thanks

Resolving patch:
diff --git a/conans/model/scm.py b/conans/model/scm.py
--- a/conans/model/scm.py
+++ b/conans/model/scm.py
@@ -46,7 +46,7 @@ def __repr__(self):
         d = {"url": self.url, "revision": self.revision, "username": self.username,
              "password": self.password, "type": self.type, "verify_ssl": self.verify_ssl,
              "subfolder": self.subfolder, "submodule": self.submodule}
-        d = {k: v for k, v in d.items() if v}
+        d = {k: v for k, v in d.items() if v is not None and v is not ""}
         return json.dumps(d, sort_keys=True)
 
 


Test patch:
diff --git a/conans/test/functional/scm/scm_test.py b/conans/test/functional/scm/scm_test.py
--- a/conans/test/functional/scm/scm_test.py
+++ b/conans/test/functional/scm/scm_test.py
@@ -869,7 +869,7 @@ def build(self):
 
     def test_scm_serialization(self):
         data = {"url": "myurl", "revision": "23", "username": "myusername",
-                "password": "mypassword", "type": "svn", "verify_ssl": True,
+                "password": "mypassword", "type": "svn", "verify_ssl": False,
                 "subfolder": "mysubfolder"}
         conanfile = namedtuple("ConanfileMock", "scm")(data)
         scm_data = SCMData(conanfile)