Sourcetreeで自組織のSSL証明書を利用する

Sourcetreeで自組織のSSL証明書を利用する場合の設定手順を紹介します。
補足
Sourcetreeでは、SSL証明書の検証確認をしないオプションも利用できます。このオプションを利用すると、自組織のCA証明書が配置されていなくても リポジトリの操作をすることができます。設定手順についてはこちらの記事を参照してください。

自組織のCA(認証局/中間認証局)証明書の配置

自組織のSSL証明書のコードサイニング元のCAの証明書をアクセスするPCに配置します。
Webブラウザなどでは、Windowsの証明書ストアに登録する方式で問題ないですが、Gitのアクセスの場合はGitの参照する証明書を指定する必要があります。

CAの証明書のファイル位置

ファイルの位置は下記のパスになります。
C:\Users\(現在のユーザー名)\AppData\Local\Atlassian\SourceTree\git_local\mingw32\ssl\certs

C:\Users\Penta\AppData\Local\Atlassian\SourceTree\git_local\mingw32\ssl\certs

certsフォルダに、自組織のCAの証明書を配置します。
ca-bundle.crt ca-bundle.trust.crt ファイルがデフォルトで配置されているファイルです。今回、自組織のCA証明書ファイル iPentec-CA-ACA.cer ファイルを追加で配置しています。

gitconfigの修正

続いてgitconfigを修正して、証明書を参照する設定を追加します。

gitconfigのファイル位置

ファイルの位置は下記のパスになります。
C:\Users\(現在のユーザー名)\AppData\Local\Atlassian\SourceTree\git_local\etc\gitconfig

C:\Users\Penta\AppData\Local\Atlassian\SourceTree\git_local\etc\gitconfig

変更内容

gitconfigファイルに下記の設定を追記します。
[http "(接続するgitホスト)"]
	sslCAinfo = (参照するSSL証明書のパス)

修正例

gitconfig (編集前)
[core]
	symlinks = false
	autocrlf = true
	fscache = true
[color]
	diff = auto
	status = auto
	branch = auto
	interactive = true
[pack]
	packSizeLimit = 2g
[help]
	format = html
[diff "astextplain"]
	textconv = astextplain
[rebase]
	autosquash = true
[filter "lfs"]
	clean = git-lfs clean -- %f
	smudge = git-lfs smudge -- %f
	process = git-lfs filter-process
	required = true
[credential]
	helper = helper-selector
gitconfig (編集後)
[core]
	symlinks = false
	autocrlf = true
	fscache = true
[color]
	diff = auto
	status = auto
	branch = auto
	interactive = true
[pack]
	packSizeLimit = 2g
[help]
	format = html
[http "https://kobako"]
	sslCAinfo = /ssl/certs/iPentec-CA-ACA.cer
[diff "astextplain"]
	textconv = astextplain
[rebase]
	autosquash = true
[filter "lfs"]
	clean = git-lfs clean -- %f
	smudge = git-lfs smudge -- %f
	process = git-lfs filter-process
	required = true
[credential]
	helper = helper-selector
著者
iPentecのメインプログラマー
C#, ASP.NET の開発がメイン、少し前まではDelphiを愛用
最終更新日: 2020-09-06
作成日: 2020-08-22
iPentec all rights reserverd.