Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
bitmask-vpn
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
leap
bitmask-vpn
Commits
c6bca076
Commit
c6bca076
authored
6 months ago
by
Pea Nut
Committed by
jkito
5 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Improve error handling when checking downloaded pem cert
We access pkBlock.Type later and pkBlock can be nil here.
parent
1f91f6f8
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!265
enable setting introducer url using env variable
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pkg/vpn/openvpn.go
+4
-3
4 additions, 3 deletions
pkg/vpn/openvpn.go
pkg/vpn/utils.go
+3
-2
3 additions, 2 deletions
pkg/vpn/utils.go
with
7 additions
and
5 deletions
pkg/vpn/openvpn.go
+
4
−
3
View file @
c6bca076
...
@@ -329,9 +329,10 @@ func (b *Bitmask) getCert() error {
...
@@ -329,9 +329,10 @@ func (b *Bitmask) getCert() error {
}
}
b
.
certPemPath
=
b
.
getTempCertPemPath
()
b
.
certPemPath
=
b
.
getTempCertPemPath
()
// If we start OpenVPN, openvpn.pem does not exist and isValidCert returns false
// If we start OpenVPN for the first time, openvpn.pem does not exist
// If we start OpenVPN later again (not restarting the client), there
// and isValidCert returns false
// should be a valid openvpn.pem
// If we start OpenVPN later again (not restarting the client), there
// should be a valid openvpn.pem and isValidCert should return true
// If there is no valid openvpn.pem, fetch a new one from menshen
// If there is no valid openvpn.pem, fetch a new one from menshen
// Note: b.tempdir is unique for every run of the desktop client
// Note: b.tempdir is unique for every run of the desktop client
if
!
isValidCert
(
b
.
certPemPath
)
{
if
!
isValidCert
(
b
.
certPemPath
)
{
...
...
This diff is collapsed.
Click to expand it.
pkg/vpn/utils.go
+
3
−
2
View file @
c6bca076
...
@@ -40,18 +40,19 @@ func isUpgradeAvailable() bool {
...
@@ -40,18 +40,19 @@ func isUpgradeAvailable() bool {
func
isValidCert
(
path
string
)
bool
{
func
isValidCert
(
path
string
)
bool
{
log
.
Trace
()
.
log
.
Trace
()
.
Str
(
"path"
,
path
)
.
Str
(
"path"
,
path
)
.
Msg
(
"Checking for
a
valid OpenVPN client credentials (key and certificate)"
)
Msg
(
"Checking for valid OpenVPN client credentials (key and certificate)"
)
data
,
err
:=
ioutil
.
ReadFile
(
path
)
data
,
err
:=
ioutil
.
ReadFile
(
path
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Debug
()
.
log
.
Debug
()
.
Str
(
"path"
,
path
)
.
Str
(
"path"
,
path
)
.
Str
(
"err"
,
err
.
Error
())
.
Msg
(
"Could not read certificate file"
)
Msg
(
"Could not read certificate file"
)
return
false
return
false
}
}
pkBlock
,
rest
:=
pem
.
Decode
(
data
)
pkBlock
,
rest
:=
pem
.
Decode
(
data
)
if
rest
==
nil
{
if
rest
==
nil
||
pkBlock
==
nil
{
log
.
Warn
()
.
log
.
Warn
()
.
Str
(
"data"
,
string
(
data
))
.
Str
(
"data"
,
string
(
data
))
.
Msg
(
"Could not decode pem data"
)
Msg
(
"Could not decode pem data"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment