Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
d975074e
Commit
d975074e
authored
Dec 19, 2018
by
Ahmad Hassan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Log certificate loading errors into sentry
parent
32c4f70a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
4 deletions
+24
-4
lib/gitlab/gitaly_client.rb
lib/gitlab/gitaly_client.rb
+8
-4
spec/lib/gitlab/gitaly_client_spec.rb
spec/lib/gitlab/gitaly_client_spec.rb
+16
-0
No files found.
lib/gitlab/gitaly_client.rb
View file @
d975074e
...
...
@@ -57,18 +57,22 @@ module Gitlab
end
end
def
self
.
stub_certs
return
@certs
if
@certs
def
self
.
stub_cert_paths
cert_paths
=
Dir
[
"
#{
OpenSSL
::
X509
::
DEFAULT_CERT_DIR
}
/*"
]
cert_paths
<<
OpenSSL
::
X509
::
DEFAULT_CERT_FILE
if
File
.
exist?
OpenSSL
::
X509
::
DEFAULT_CERT_FILE
cert_paths
end
def
self
.
stub_certs
return
@certs
if
@certs
@certs
=
cert_paths
.
flat_map
do
|
cert_file
|
@certs
=
stub_
cert_paths
.
flat_map
do
|
cert_file
|
File
.
read
(
cert_file
).
scan
(
PEM_REGEX
).
map
do
|
cert
|
begin
OpenSSL
::
X509
::
Certificate
.
new
(
cert
).
to_pem
rescue
OpenSSL
::
OpenSSLError
=>
e
Rails
.
logger
.
error
"Could not load certificate
#{
cert_file
}
#{
e
}
"
Gitlab
::
Sentry
.
track_exception
(
e
,
extra:
{
cert_file:
cert_file
})
nil
end
end
.
compact
...
...
spec/lib/gitlab/gitaly_client_spec.rb
View file @
d975074e
...
...
@@ -30,6 +30,22 @@ describe Gitlab::GitalyClient do
end
end
describe
'.stub_certs'
do
it
'skips certificates if OpenSSLError is raised and report it'
do
expect
(
Rails
.
logger
).
to
receive
(
:error
).
at_least
(
:once
)
expect
(
Gitlab
::
Sentry
)
.
to
receive
(
:track_exception
)
.
with
(
a_kind_of
(
OpenSSL
::
X509
::
CertificateError
),
extra:
{
cert_file:
a_kind_of
(
String
)
}).
at_least
(
:once
)
expect
(
OpenSSL
::
X509
::
Certificate
)
.
to
receive
(
:new
)
.
and_raise
(
OpenSSL
::
X509
::
CertificateError
).
at_least
(
:once
)
expect
(
described_class
.
stub_certs
).
to
be_a
(
String
)
end
end
describe
'.stub_creds'
do
it
'returns :this_channel_is_insecure if unix'
do
address
=
'unix:/tmp/gitaly.sock'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment