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
083f4095
Unverified
Commit
083f4095
authored
3 years ago
by
Kali Kaneko
Browse files
Options
Downloads
Patches
Plain Diff
[feat] reuse certificate if found in config folder
parent
1d0bdcd6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
docs/circumvention.rst
+25
-0
25 additions, 0 deletions
docs/circumvention.rst
pkg/vpn/certs.go
+34
-0
34 additions, 0 deletions
pkg/vpn/certs.go
pkg/vpn/main.go
+1
-1
1 addition, 1 deletion
pkg/vpn/main.go
pkg/vpn/openvpn.go
+22
-12
22 additions, 12 deletions
pkg/vpn/openvpn.go
with
82 additions
and
13 deletions
docs/circumvention.rst
0 → 100644
+
25
−
0
View file @
083f4095
Censorship Circumvention
================================================================================
This document contains some advice for using BitmaskVPN for censorship
circumvention.
Bootstrapping the connection
-----------------------------
There are two different steps where circumvention can be used: boostrapping the
connection (getting a certificate and the configuration files) and using an
obfuscated transport protocol. At the moment RiseupVPN offers obfs4 transport
"bridges" (you can try them with the `--obfs4` command line argument). For the
initial bootstrap, there are a couple of techniques that will be attempted.
Getting certificates off-band
-----------------------------
As a last resort, you can place a valid certificate in the config folder (name
it after the provider domain). You might have downloaded this cert with Tor,
using a socks proxy etc...
~/.config/leap/riseup.net.pem
When the certificate expires you will need to download a new one.
This diff is collapsed.
Click to expand it.
pkg/vpn/certs.go
0 → 100644
+
34
−
0
View file @
083f4095
package
vpn
import
(
"crypto/x509"
"encoding/pem"
"io/ioutil"
"log"
"time"
)
func
isValidCert
(
path
string
)
bool
{
data
,
err
:=
ioutil
.
ReadFile
(
path
)
if
err
!=
nil
{
return
false
}
// skip private key, but there should be one
_
,
rest
:=
pem
.
Decode
(
data
)
certBlock
,
rest
:=
pem
.
Decode
(
rest
)
if
len
(
rest
)
!=
0
{
log
.
Println
(
"ERROR bad cert data"
)
return
false
}
cert
,
err
:=
x509
.
ParseCertificate
(
certBlock
.
Bytes
)
loc
,
_
:=
time
.
LoadLocation
(
"UTC"
)
expires
:=
cert
.
NotAfter
tomorrow
:=
time
.
Now
()
.
In
(
loc
)
.
Add
(
24
*
time
.
Hour
)
if
!
expires
.
After
(
tomorrow
)
{
return
false
}
else
{
log
.
Println
(
"DEBUG We have a valid cert:"
,
path
)
return
true
}
}
This diff is collapsed.
Click to expand it.
pkg/vpn/main.go
+
1
−
1
View file @
083f4095
...
...
@@ -68,7 +68,7 @@ func Init() (*Bitmask, error) {
}
*/
err
=
ioutil
.
WriteFile
(
b
.
getCaCertPath
(),
config
.
CaCert
,
0600
)
err
=
ioutil
.
WriteFile
(
b
.
get
Temp
CaCertPath
(),
config
.
CaCert
,
0600
)
go
b
.
openvpnManagement
()
return
&
b
,
err
...
...
This diff is collapsed.
Click to expand it.
pkg/vpn/openvpn.go
+
22
−
12
View file @
083f4095
...
...
@@ -22,9 +22,11 @@ import (
"log"
"os"
"path"
"path/filepath"
"strconv"
"strings"
"0xacab.org/leap/bitmask-vpn/pkg/config"
"0xacab.org/leap/shapeshifter"
)
...
...
@@ -167,7 +169,7 @@ func (b *Bitmask) startOpenVPN() error {
"--verb"
,
"3"
,
"--management-client"
,
"--management"
,
openvpnManagementAddr
,
openvpnManagementPort
,
"--ca"
,
b
.
getCaCertPath
(),
"--ca"
,
b
.
get
Temp
CaCertPath
(),
"--cert"
,
b
.
certPemPath
,
"--key"
,
b
.
certPemPath
,
"--persist-tun"
)
...
...
@@ -175,17 +177,25 @@ func (b *Bitmask) startOpenVPN() error {
}
func
(
b
*
Bitmask
)
getCert
()
(
certPath
string
,
err
error
)
{
certPath
=
b
.
getCertPemPath
()
if
_
,
err
:=
os
.
Stat
(
certPath
);
os
.
IsNotExist
(
err
)
{
log
.
Println
(
"Fetching certificate to"
,
certPath
)
cert
,
err
:=
b
.
bonafide
.
GetPemCertificate
()
if
err
!=
nil
{
return
""
,
err
persistentCertFile
:=
filepath
.
Join
(
config
.
Path
,
strings
.
ToLower
(
config
.
Provider
)
+
".pem"
)
if
_
,
err
:=
os
.
Stat
(
persistentCertFile
);
!
os
.
IsNotExist
(
err
)
&&
isValidCert
(
persistentCertFile
)
{
// reuse cert. for the moment we're not writing one there, this is
// only to allow users to get certs off-band and place them there
// as a last-resort fallback for circumvention.
certPath
=
persistentCertFile
err
=
nil
}
else
{
// download one fresh
certPath
=
b
.
getTempCertPemPath
()
if
_
,
err
:=
os
.
Stat
(
certPath
);
os
.
IsNotExist
(
err
)
{
log
.
Println
(
"Fetching certificate to"
,
certPath
)
cert
,
err
:=
b
.
bonafide
.
GetPemCertificate
()
if
err
!=
nil
{
return
""
,
err
}
err
=
ioutil
.
WriteFile
(
certPath
,
cert
,
0600
)
}
err
=
ioutil
.
WriteFile
(
certPath
,
cert
,
0600
)
}
return
certPath
,
err
}
...
...
@@ -299,10 +309,10 @@ func (b *Bitmask) UseTransport(transport string) error {
return
nil
}
func
(
b
*
Bitmask
)
getCertPemPath
()
string
{
func
(
b
*
Bitmask
)
get
Temp
CertPemPath
()
string
{
return
path
.
Join
(
b
.
tempdir
,
"openvpn.pem"
)
}
func
(
b
*
Bitmask
)
getCaCertPath
()
string
{
func
(
b
*
Bitmask
)
get
Temp
CaCertPath
()
string
{
return
path
.
Join
(
b
.
tempdir
,
"cacert.pem"
)
}
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