Konfiguration des selbstsignierten Git-Zertifikats
tl;dr
Deaktivieren Sie NIEMALS die gesamte SSL-Verifizierung!
Dies schafft eine schlechte Sicherheitskultur. Seien Sie nicht so eine Person.
Die gesuchten Konfigurationsschlüssel sind:
Diese sind für die Konfiguration von Host-Zertifikaten, denen Sie vertrauen
Sie dienen dazu, IHR Zertifikat so zu konfigurieren, dass es auf SSL-Herausforderungen reagiert.
Wenden Sie die oben genannten Einstellungen selektiv auf bestimmte Hosts an.
Global .gitconfig
für selbstsignierte Zertifizierungsstellen
Für mich und meine Kollegen haben wir es geschafft, selbstsignierte Zertifikate zum Laufen zu bringen, ohne sie zu deaktivieren sslVerify
. Bearbeiten Sie Ihr .gitconfig
zu verwenden git config --global -e
diese hinzufügen:
# Specify the scheme and host as a 'context' that only these settings apply
# Must use Git v1.8.5+ for these contexts to work
[credential "https://your.domain.com"]
username = user.name
# Uncomment the credential helper that applies to your platform
# Windows
# helper = manager
# OSX
# helper = osxkeychain
# Linux (in-memory credential helper)
# helper = cache
# Linux (permanent storage credential helper)
# https://askubuntu.com/a/776335/491772
# Specify the scheme and host as a 'context' that only these settings apply
# Must use Git v1.8.5+ for these contexts to work
[http "https://your.domain.com"]
##################################
# Self Signed Server Certificate #
##################################
# MUST be PEM format
# Some situations require both the CAPath AND CAInfo
sslCAInfo = /path/to/selfCA/self-signed-certificate.crt
sslCAPath = /path/to/selfCA/
sslVerify = true
###########################################
# Private Key and Certificate information #
###########################################
# Must be PEM format and include BEGIN CERTIFICATE / END CERTIFICATE,
# not just the BEGIN PRIVATE KEY / END PRIVATE KEY for Git to recognise it.
sslCert = /path/to/privatekey/myprivatecert.pem
# Even if your PEM file is password protected, set this to false.
# Setting this to true always asks for a password even if you don't have one.
# When you do have a password, even with this set to false it will prompt anyhow.
sslCertPasswordProtected = 0
Referenzen:
Konfiguration angeben, wenn git clone
-ing
Wenn Sie es pro Projektarchiv anwenden müssen, sagt Ihnen die Dokumentation, dass Sie einfach git config --local
in Ihrem Repo-Verzeichnis. Nun, das ist nicht nützlich, wenn Sie die Repo noch nicht lokal geklont haben, nicht wahr?
Sie können die global -> local
hokey-pokey, indem Sie Ihre globale Konfiguration wie oben einstellen und diese Einstellungen dann in Ihre lokale Repo-Konfiguration kopieren, sobald es geklont ist...
ODER was Sie tun können, ist geben Sie Konfigurationsbefehle unter git clone
die auf das Ziel-Repositorium angewendet werden, sobald es geklont ist.
# Declare variables to make clone command less verbose
OUR_CA_PATH=/path/to/selfCA/
OUR_CA_FILE=$OUR_CA_PATH/self-signed-certificate.crt
MY_PEM_FILE=/path/to/privatekey/myprivatecert.pem
SELF_SIGN_CONFIG="-c http.sslCAPath=$OUR_CA_PATH -c http.sslCAInfo=$OUR_CA_FILE -c http.sslVerify=1 -c http.sslCert=$MY_PEM_FILE -c http.sslCertPasswordProtected=0"
# With this environment variable defined it makes subsequent clones easier if you need to pull down multiple repos.
git clone $SELF_SIGN_CONFIG https://mygit.server.com/projects/myproject.git myproject/
Einzeiler
EDIT: Siehe VonC 's Antwort der auf einen Vorbehalt bezüglich absoluter und relativer Pfade für bestimmte Git-Versionen von 2.14.x/2.15 bis zu dieser einen Zeile hinweist
git clone -c http.sslCAPath="/path/to/selfCA" -c http.sslCAInfo="/path/to/selfCA/self-signed-certificate.crt" -c http.sslVerify=1 -c http.sslCert="/path/to/privatekey/myprivatecert.pem" -c http.sslCertPasswordProtected=0 https://mygit.server.com/projects/myproject.git myproject/
CentOS unable to load client key
Wenn Sie dies unter CentOS versuchen und Ihr .pem
Datei gibt Ihnen
unable to load client key: "-8178 (SEC_ERROR_BAD_KEY)"
Dann werden Sie wollen diese StackOverflow-Antwort darüber, wie curl
verwendet NSS anstelle von Open SSL.
Und Sie werden es gerne tun wiederherstellen curl
von der Quelle :
git clone http://github.com/curl/curl.git curl/
cd curl/
# Need these for ./buildconf
yum install autoconf automake libtool m4 nroff perl -y
#Need these for ./configure
yum install openssl-devel openldap-devel libssh2-devel -y
./buildconf
su # Switch to super user to install into /usr/bin/curl
./configure --with-openssl --with-ldap --with-libssh2 --prefix=/usr/
make
make install
Computer neu starten, da libcurl noch als gemeinsam genutzte Bibliothek im Speicher ist
Python, pip und conda
Verwandte Seiten : Wie fügt man ein benutzerdefiniertes CA-Root-Zertifikat zum CA-Speicher hinzu, der von pip in Windows verwendet wird?