lfshttp/certs_darwin: filter CA certs that are only fuzzy matches of CN#6037
lfshttp/certs_darwin: filter CA certs that are only fuzzy matches of CN#6037stanhu wants to merge 1 commit intogit-lfs:mainfrom
Conversation
458ba8a to
eaa5a7b
Compare
In our organization (`example.org`), we use the Jamf endpoint, which adds a self-signed SSL certificate with the CN: ``` CN=example.org JSS Built-in Certificate Authority ``` This causes SSL validation to fail when accessing Git LFS on `example.org`: ``` Post "https://example.org/group/project/info/lfs/locks/verify": x509: certificate signed by unknown authority ``` This is happening because: 1. When accessing `example.org` endpoints, Git LFS checks if there are any custom certificates to trust for that host. 2. It calls `appendRootCAsForHostFromKeychain` with the hostname `example.org`. 3. This function executes `/usr/bin/security find-certificate -a -p -c example.org <keychain>`, which performs a substring match on the Common Name. 4. If the System keychain contains a certificate with CN `example.org JSS Built-in Certificate Authority`, this gets returned by the fuzzy match. 5. Git LFS then adds this CA certificate to the trust store for connections to `example.org`. 6. When connecting to the real `example.org`, Git LFS is now trying to validate the official TLS certificate against this self-signed JAMF CA certificate, which will always fail. Because `/usr/bin/security find-certificate` does not support exact matches, this commit filters out non-matching CNs to avoid using the wrong cert for the given domain. Closes git-lfs#6037
eaa5a7b to
125c1fb
Compare
In our organization (`example.org`), we use the Jamf endpoint, which adds a self-signed SSL certificate with the CN: ``` CN=example.org JSS Built-in Certificate Authority ``` This causes SSL validation to fail when accessing Git LFS on `example.org`: ``` Post "https://example.org/group/project/info/lfs/locks/verify": x509: certificate signed by unknown authority ``` This is happening because: 1. When accessing `example.org` endpoints, Git LFS checks if there are any custom certificates to trust for that host. 2. It calls `appendRootCAsForHostFromKeychain` with the hostname `example.org`. 3. This function executes `/usr/bin/security find-certificate -a -p -c example.org <keychain>`, which performs a substring match on the Common Name. 4. If the System keychain contains a certificate with CN `example.org JSS Built-in Certificate Authority`, this gets returned by the fuzzy match. 5. Git LFS then adds this CA certificate to the trust store for connections to `example.org`. 6. When connecting to the real `example.org`, Git LFS is now trying to validate the official TLS certificate against this self-signed JAMF CA certificate, which will always fail. Because `/usr/bin/security find-certificate` does not support exact matches, this commit filters out non-matching CNs to avoid using the wrong cert for the given domain. Closes git-lfs#6037
125c1fb to
2ffdeef
Compare
In our organization (`example.org`), we use the Jamf endpoint, which adds a self-signed SSL certificate with the CN: ``` CN=example.org JSS Built-in Certificate Authority ``` This causes SSL validation to fail when accessing Git LFS on `example.org`: ``` Post "https://example.org/group/project/info/lfs/locks/verify": x509: certificate signed by unknown authority ``` This is happening because: 1. When accessing `example.org` endpoints, Git LFS checks if there are any custom certificates to trust for that host. 2. It calls `appendRootCAsForHostFromKeychain` with the hostname `example.org`. 3. This function executes `/usr/bin/security find-certificate -a -p -c example.org <keychain>`, which performs a substring match on the Common Name. 4. If the System keychain contains a certificate with CN `example.org JSS Built-in Certificate Authority`, this gets returned by the fuzzy match. 5. Git LFS then adds this CA certificate to the trust store for connections to `example.org`. 6. When connecting to the real `example.org`, Git LFS is now trying to validate the official TLS certificate against this self-signed JAMF CA certificate, which will always fail. Because `/usr/bin/security find-certificate` does not support exact matches, this commit filters out non-matching CNs to avoid using the wrong cert for the given domain. Closes git-lfs#6037
2ffdeef to
2037b79
Compare
In our organization (`example.org`), we use the Jamf endpoint, which adds a self-signed SSL certificate with the CN: ``` CN=example.org JSS Built-in Certificate Authority ``` This causes SSL validation to fail when accessing Git LFS on `example.org`: ``` Post "https://example.org/group/project/info/lfs/locks/verify": x509: certificate signed by unknown authority ``` This is happening because: 1. When accessing `example.org` endpoints, Git LFS checks if there are any custom certificates to trust for that host. 2. It calls `appendRootCAsForHostFromKeychain` with the hostname `example.org`. 3. This function executes `/usr/bin/security find-certificate -a -p -c example.org <keychain>`, which performs a substring match on the Common Name. 4. If the System keychain contains a certificate with CN `example.org JSS Built-in Certificate Authority`, this gets returned by the fuzzy match. 5. Git LFS then adds this CA certificate to the trust store for connections to `example.org`. 6. When connecting to the real `example.org`, Git LFS is now trying to validate the official TLS certificate against this self-signed JAMF CA certificate, which will always fail. Because `/usr/bin/security find-certificate` does not support exact matches, this commit filters out non-matching CNs to avoid using the wrong cert for the given domain. Closes git-lfs#6037
6e78656 to
510ee42
Compare
In our organization (`example.org`), we use the Jamf endpoint, which adds a self-signed SSL certificate with the CN: ``` CN=example.org JSS Built-in Certificate Authority ``` This causes SSL validation to fail when accessing Git LFS on `example.org`: ``` Post "https://example.org/group/project/info/lfs/locks/verify": x509: certificate signed by unknown authority ``` This is happening because: 1. When accessing `example.org` endpoints, Git LFS checks if there are any custom certificates to trust for that host. 2. It calls `appendRootCAsForHostFromKeychain` with the hostname `example.org`. 3. This function executes `/usr/bin/security find-certificate -a -p -c example.org <keychain>`, which performs a substring match on the Common Name. 4. If the System keychain contains a certificate with CN `example.org JSS Built-in Certificate Authority`, this gets returned by the fuzzy match. 5. Git LFS then adds this CA certificate to the trust store for connections to `example.org`. 6. When connecting to the real `example.org`, Git LFS is now trying to validate the official TLS certificate against this self-signed JAMF CA certificate, which will always fail. Because `/usr/bin/security find-certificate` does not support exact matches, this commit filters out non-matching CNs to avoid using the wrong cert for the given domain. Closes git-lfs#6036
510ee42 to
f941108
Compare
| // but not an exact match (like "example.com JSS Built-in Certificate Authority") | ||
| if cert.IsCA && | ||
| strings.Contains(cert.Subject.CommonName, hostname) && | ||
| !strings.EqualFold(cert.Subject.CommonName, hostname) { |
There was a problem hiding this comment.
Hmm, this is problematic if you happen to have a TLS cert that requires this bundle:
example.orgexample.org Intermediate CAexample.org Root CA
It's possible all three certs are needed here? I guess this is really a problem with /usr/bin/security find-certificate not doing exact matching, or these intermediate certificates having a misleading CN?
|
Hey, thanks for this pull request and the description of the issue it is designed to address! We really appreciate contributions like these which include tests and a thorough explanation of how the changes are intended to operate. I'll aim to take a closer look as soon as possible, with the caveat that it might take me a little while before I can give this the careful review it deserves. Thank you again very much for this PR! |
|
Closing in favor of #6049. |
In our organization (
example.org), we use the Jamf endpoint, which adds a self-signed SSL certificate with the CN:This causes SSL validation to fail when accessing Git LFS on
example.org:This is happening because:
example.orgendpoints, Git LFS checks if there are any custom certificates to trust for that host.appendRootCAsForHostFromKeychainwith the hostnameexample.org./usr/bin/security find-certificate -a -p -c example.org <keychain>, which performs a substring match on the Common Name.example.org JSS Built-in Certificate Authority, this gets returned by the fuzzy match.example.org.example.org, Git LFS is now trying to validate the official TLS certificate against this self-signed JAMF CA certificate, which will always fail.Because
/usr/bin/security find-certificatedoes not support exact matches, this commit filters out non-matching CNs to avoid using the wrong cert for the given domain.Resolves #6036.