Для доступа к репозиторию git, защищенному самоподписанным сертификатом, нужно в файле ~/.gitconfig
прописать секцию http
для этого репозитория (предполагаем, что доступ осуществляется по сертификату и ключу):
[http "https://remoteserver.site"]
sslVerify = false
sslCert = /path/to/cert/cert.pem
sslKey = /path/to/cert/key.pem
Работает замечательно, только не в MacOS X, где при попытке доступа к репозиторию возникает ошибка:
git clone https://remoteserver.site/rep.git
Cloning into 'sugarcrm'...
* Couldn't find host remoteserver.site in the .netrc file; using defaults
* Trying 11.22.33.44...
* Connected to remoteserver.site (11.22.33.44) port 443 (#0)
* WARNING: SSL: CURLOPT_SSLKEY is ignored by Secure Transport. The private key must be in the Keychain.
* WARNING: SSL: Certificate type not set, assuming PKCS#12 format.
* SSL: Can't load the certificate "/path/to/cert/cert.pem" and its private key: OSStatus -25299
* Closing connection 0
fatal: unable to access 'https://remoteserver.site/rep.git/': SSL: Can't load the certificate "/path/to/cert/cert.pem" and its private key: OSStatus -25299
Подробнее о причинах можно почитать здесь.
Есть несколько решений этой проблемы. Первое - переустановить curl с поддержкой OpenSSL (источник):
brew install curl --with-openssl
brew link curl --force
hash -r
curl
Или преобразовать имеющийся сертфикат в формат PKCS#12
:
openssl pkcs12 -export -in ./cert.pem -inkey ./key.pem -out cert.p12
И привести настройки git'а к следующему виду:
[http "https://remoteserver.site"]
sslVerify = false
sslCert = /path/to/cert.p12
sslCertPasswordProtected = true
Updated
Чтобы git постоянно не спрашивал пароль на сертификат, можно сертификат сложить в KeyChain (в Finder'e дважды кликнуть на него и ввести пароль) и в .gitconfig
прописать:
[http "https://remoteserver.site"]
sslVerify = false
sslCert = cert #(это имя сертификата в связке KeyChain)
sslCertPasswordProtected = false