Yuuri
Fleet Admiral
- Registriert
- Okt. 2010
- Beiträge
- 13.928
Hallo zusammen,
ich beiß mir grad die Zähne an obiger Direktive aus.
Ich hab mir auf meinem Server mittels VMWare eine GitLab VM erstellt. Zugriff erfolgt über den Apache auf dem Server selbst, der die Anfragen nur per mod_proxy weiterleitet. Funktioniert wunderbar. Eigentlich irrelevant, wollts nur zur Info erwähnen.
Der Zugriff erfolgt über HTTPS, das self signed Certificate macht aber natürlich Probleme. Mit der Umgebungsvariable GIT_SSL_NO_VERIFY funktionierts, ist aber nicht Sinn der Sache. Änder ich http.sslCAInfo global (%userprofile%\.gitconfig), bekomm ich natürlich Probleme, weil die anderen Zertifikate nicht mehr registriert sind. Ergo bleibt mir nur das Setzen von http.sslCAPath. Die Zertifikate im gesetzten Verzeichnis liegen im PEM-Format
vor, wie eben jene in C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt. Das Zertifikat selbst ist eigentlich ein Wildcard-Zeritifkat, inwiefern das dabei in git reinspielt, weiß ich nicht. Die Zertifikate in sslCAPath liegen alle mit entsprechendem Hostnamen als Dateinamen mit .crt, .pem und ohne Extension vor.
Seh ich mir den Zugriff dabei im Process Monitor an, gibts allerdings von git-remote-https.exe einen Zugriff auf den gesetzten Pfad und die Datei 80703266.0. Kopier ich das Zeritfikat nun in diese Datei, funktioniert der Zugriff einwandfrei. Weiterhin erfolgt ein Zugriff auf 80703266.1, wobei ich keinerlei Ahnung hab wieso. Der Push o.ä. ist trotzdem erfolgreich gewesen.
Kann mir das einer erklären?
In den Weiten des Internets hab ich nix gefunden zur Arbeitsweise... Einzig einen Post ohne Antwort. Außer sinnlose "verwende sslCAPath"-Posts gibts rein gar nix dazu. Die Doku ist auch fürn Hintern.
LG
Habs "gestern" noch selbst rausgefunden. Zur Erklärung, falls ein Anderer drauf stößt:
http.sslCAPath wird direkt an curl weitergereicht. Der entsprechende Switch wäre --capath. curl nutzt seinerseits OpenSSL und darin die c_rehash Funktion. Wie man dann auf dieser Seite sehen kann, wird ein Hash des Zertifikats berechnet (HHHHHHHH.D; H = Hex, D = Index). Theoretisch soll diese Funktion auch die Symlinks (HHH...D) erstellen, was es bei mir aber nicht macht. Demzufolge kommt der Zugriff auf obige Datei.
Hab mir da zur Abhilfe ein kleines PowerShell Script geschrieben, was das für mich erledigt.
Vielleicht brauch es auch jemand:
ich beiß mir grad die Zähne an obiger Direktive aus.
Ich hab mir auf meinem Server mittels VMWare eine GitLab VM erstellt. Zugriff erfolgt über den Apache auf dem Server selbst, der die Anfragen nur per mod_proxy weiterleitet. Funktioniert wunderbar. Eigentlich irrelevant, wollts nur zur Info erwähnen.
Der Zugriff erfolgt über HTTPS, das self signed Certificate macht aber natürlich Probleme. Mit der Umgebungsvariable GIT_SSL_NO_VERIFY funktionierts, ist aber nicht Sinn der Sache. Änder ich http.sslCAInfo global (%userprofile%\.gitconfig), bekomm ich natürlich Probleme, weil die anderen Zertifikate nicht mehr registriert sind. Ergo bleibt mir nur das Setzen von http.sslCAPath. Die Zertifikate im gesetzten Verzeichnis liegen im PEM-Format
Code:
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
Code:
.example.com # wegen Wildcard
.example.com.crt # wegen Wildcard
.example.com.pem # wegen Wildcard
git.example.com
git.example.com.crt
git.example.com.pem
Kann mir das einer erklären?
In den Weiten des Internets hab ich nix gefunden zur Arbeitsweise... Einzig einen Post ohne Antwort. Außer sinnlose "verwende sslCAPath"-Posts gibts rein gar nix dazu. Die Doku ist auch fürn Hintern.
LG
Ergänzung ()
Habs "gestern" noch selbst rausgefunden. Zur Erklärung, falls ein Anderer drauf stößt:
http.sslCAPath wird direkt an curl weitergereicht. Der entsprechende Switch wäre --capath. curl nutzt seinerseits OpenSSL und darin die c_rehash Funktion. Wie man dann auf dieser Seite sehen kann, wird ein Hash des Zertifikats berechnet (HHHHHHHH.D; H = Hex, D = Index). Theoretisch soll diese Funktion auch die Symlinks (HHH...D) erstellen, was es bei mir aber nicht macht. Demzufolge kommt der Zugriff auf obige Datei.
Hab mir da zur Abhilfe ein kleines PowerShell Script geschrieben, was das für mich erledigt.
Vielleicht brauch es auch jemand:
Code:
<#
.SYNOPSIS
Creates hardlinks of certificates which reside in git's http.sslCAPath to resolve correctly.
.DESCRIPTION
git's http.sslCAPath uses curl's --capath switch which references OpenSSL's c_rehash function.
Setting http.sslCAPath and copying certificates into it doesn't make it work. The certificates
have to be hashed and linked first in order to work correctly. This Cmdlet reads the gitconfig
of the user, finds each certificate (.crt or .pem) in the path given in http.sslCAPath, lets
OpenSSL manually hash the certificate and hardlinks the certificates to their corresponding
hash.
c_rehash states it links certificates automatically, but in my case it doesn't. So this script
was born.
.PARAMETER OpenSslExecutablePath
Path to openssl.exe
Will be automatically found if openssl.exe lies inside $env:Path.
.EXAMPLE
Invoke-LinkGitCertificates
.EXAMPLE
Invoke-LinkGitCertificates -OpenSslExecutablePath C:\openssl\bin\openssl.exe
.EXAMPLE
Invoke-LinkGitCertificates -OpenSSL C:\openssl\bin\openssl.exe
.OUTPUTS
System.String[]
.NOTES
Dependencies:
New-Hardlink Cmdlet of Pscx (https://pscx.codeplex.com/)
openssl.exe of OpenSSL (https://www.openssl.org/)
.LINK
Explanation of c_rehash
https://www.openssl.org/docs/man1.0.2/apps/c_rehash.html
#>
function Invoke-LinkGitCertificates
{
[CmdletBinding()]
Param(
[Parameter(
Position = 1
)]
[Alias("OpenSSL")]
$OpenSslExecutablePath = (Where-Is openssl.exe)
)
begin
{
if( !$OpenSslExecutablePath )
{
Write-Error "openssl.exe could not be found automatically. Please provide the path manually via OpenSslExecutablePath switch. Exiting." -ErrorAction Stop
}
try { Get-Command New-Hardlink | Out-Null }
catch { Write-Error "Cmdlet New-Hardlink not found. Please download Pcsx from https://pscx.codeplex.com/." -ErrorAction Stop }
}
process
{
$GlobalGitConfigPath = Join-Path $env:USERPROFILE .gitconfig
if( Test-Path -LiteralPath $GlobalGitConfigPath )
{
Write-Verbose "Global .gitconfig exists."
$GlobalGitConfigIni = $GlobalGitConfigPath | Get-IniContent
Write-Verbose ".gitconfig parsed."
if( $GlobalGitConfigIni.http -and $GlobalGitConfigIni.http.sslCAPath )
{
Write-Verbose "http.sslCAPath key exists."
$sslCAPath = $GlobalGitConfigIni.http.sslCAPath -replace "/","\"
Write-Verbose ("http.sslCAPath = `"{0}`"" -f $sslCAPath)
dir "$sslCAPath\*" -Include *.crt,*.pem | % {
$File = $_
Write-Verbose ("Found certificate `"{0}`"." -f $File)
$Hash = & $OpenSslExecutablePath x509 -hash -fingerprint -noout -in $File.FullName
if( $Hash[0] -and $Hash[0] -match "^[0-9a-f]+$" )
{
$Hash = $Hash[0]
Write-Verbose ("Hash = {0}" -f $Hash)
rm "$sslCAPath\$Hash.*"
$LinkedCertificatePath = "$sslCAPath\$Hash.0"
New-Hardlink $LinkedCertificatePath $File.FullName | Out-Null
Write-Verbose ("linked `"{0}`" to `"{1}`"" -f $File.FullName,$LinkedCertificatePath)
$LinkedCertificatePath
}
}
}
}
}
}
PowerShell Community Extensions (PSCX)
Code:
function Get-IniContent
{
[CmdletBinding()]
Param(
[Parameter(
Mandatory = $true,
ValueFromPipeline = $true
)]
[ValidateNotNullOrEmpty()]
[ValidateScript({ Test-Path $_ -PathType Leaf })]
[Alias("Filename")]
[string]$Path,
[Alias("SkipComments","NC","SC","C")]
[switch]$NoComments,
[Alias("CommentedAssignments","ECA","CA")]
[switch]$ExcludeCommentedAssignments
)
begin
{
$IncludeComments = !$NoComments
$IncludeCommentedAssignments = !$ExcludeCommentedAssignments
$Data = @{}
}
process
{
$CurrentSection = "None"
$CommentCount = 0
(gc $Path) | % {
$Line = $_
if( $Line -match "^[#;].*" -and !$IncludeCommentedAssignments -and $Line -match ";(?<Key>.*)=(?<Value>.*)$" )
{
if( $IncludeComments )
{
if( !$Data.Contains( $CurrentSection ) ) { $Data[$CurrentSection] = @{} }
$Data[$CurrentSection]["Comment$CommentCount"] = $Line
++$CommentCount
}
}
elseif( $Line -match "^\s*\[(?<Section>.*)\]\s*$" )
{
Write-Verbose "Section => $Line"
$CurrentSection = $Matches.Section.Trim()
if( !$Data.Contains( $CurrentSection ) ) { $Data[$CurrentSection] = @{} }
$CommentCount = 0
}
elseif( $Line -match "^(?<Key>.+)=(?<Value>.*)$" )
{
Write-Verbose "KeyValue => $Line"
Write-Verbose "Key => $($Matches.Key)"
Write-Verbose "Value => $($Matches.Value)"
$k = $Matches.Key.Trim()
$v = $Matches.Value.Trim()
if( !$Data[$CurrentSection].Contains( $k ) ) { $Data[$CurrentSection][$k] = @() }
$Data[$CurrentSection][$k] += $v
}
}
}
end
{
$Data
}
}
Code:
function Where-Is
{
Param(
[Parameter(
Position = 1,
Mandatory = $true,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true
)]
[string]$Name,
[switch]$All
)
begin
{
Write-Verbose "Preparing paths..."
$Paths = (".",$env:Path) -split ";"
Write-Verbose "Preparing extensions..."
$PathExts = $env:PATHEXT -split ";"
$PathsFound = @()
}
process
{
$Done = $false
Write-Verbose "Processing..."
$Paths | % {
$p = Join-Path $_ $Name
if( !$All -and $Done ) { return }
Write-Verbose "[PATH] $p"
if( Test-Path $p -PathType Leaf )
{
$Done = $true
$PathsFound += (gi $p).FullName
return
}
$PathExts | % {
$p2 = "$p$_"
if( !$All -and $Done ) { return }
Write-Verbose " [FILE] $p2"
if( Test-Path $p2 -PathType Leaf )
{
$Done = $true
$PathsFound += (gi $p2).FullName
return;
}
}
}
Write-Verbose "Done."
}
end
{
if( $PathsFound.Length -eq 0 )
{
"`"{0}`" not found anywhere." -f $Name | Out-Host
}
else
{
$PathsFound
}
}
}