Synology-Forum.nl

Packages => Officiële Packages => VPN Server => Topic gestart door: SiJoNas op 05 januari 2019, 10:39:24

Titel: Certificaat, en automatisch starten
Bericht door: SiJoNas op 05 januari 2019, 10:39:24
Beste mensen,

Twee vragen over mijn openvpn:

1. Op mijn android telefoon blijft OpenVPN Connect vragen om een certificaat. Ik heb geprobeerd om verschillende certificaten te installeren maar het helpt niet. Na klikken op Continue wordt er wel een verbinding gemaakt. Welk certificaat moet ik waar installeren, en moet ik dit ergens in de .ovpn aangeven? Overigens vraagt mijn windows er niet om (met dezelfde .ovpn).

2. Hoe kan ik zowel mijn windows laptop als mijn telefoon zo instellen dat de vpn automatisch start, wanneer ik mijn (veilige) thuisnetwerk verlaat? En dan uiteraard ook omgekeerd: dat de vpn uitgeschakeld wordt als ik weer thuis ben.

Voor de duidelijkheid: niet alleen het programma/appje OpenVPN moet gestart worden, maar het bijbehorende profiel dus ook, anders heeft het geen zin.
Titel: Re: Certificaat, en automatisch starten
Bericht door: Briolet op 05 januari 2019, 11:28:09
In het .ovpn  bestand kan een verwijzing staan naar een extern certificaat, of het certificaat is onderdeel van het .ovpn bestand. Welk van de twee zou je eigenlijk moeten weten als je dat bestand bekijkt.

Bij mij was het vroeger het eerste en tegenwoordig het laatste. Maar die verandering kan ook aan mijn instellingen liggen. In elk geval moet je in het .ovpn bestand kijken.
Titel: Re: Certificaat, en automatisch starten
Bericht door: SiJoNas op 05 januari 2019, 13:48:44
Dit is mijn ovpn bestand, bijna standaard zoals die door de nas gemaakt wordt. Kan je hier iets aan ontdekken?

dev tun
tls-client
remote-cert-tls server
auth-nocache

remote www.###.eu 1194

# The "float" tells OpenVPN to accept authenticated packets from any address,
# not only the address which was specified in the --remote option.
# This is useful when you are connecting to a peer which holds a dynamic address
# such as a dial-in user or DHCP client.
# (Please refer to the manual of OpenVPN for more information.)

#float

# If redirect-gateway is enabled, the client will redirect it's
# default network gateway through the VPN.
# It means the VPN connection will firstly connect to the VPN Server
# and then to the internet.
# (Please refer to the manual of OpenVPN for more information.)

redirect-gateway def1

# dhcp-option DNS: To set primary domain name server address.
# Repeat this option to set secondary DNS server addresses.

# dhcp-option DNS 1.1.1.1

pull

# If you want to connect by Server's IPv6 address, you should use
# "proto udp6" in UDP mode or "proto tcp6-client" in TCP mode
proto udp

script-security 2


comp-lzo

reneg-sec 0

cipher AES-256-CBC

auth SHA512

auth-user-pass
<ca>
-----BEGIN CERTIFICATE-----
MIIF2DCCA8CgAwIBAgIQTKr5yttjb+Af907YWwOGnTANBgkqhkiG9w0BAQwFADCB
...
0MC2Hb46TpSi125sC8KKfPog88Tk5c0NqMuRkrF8hey1FGlmDoLnzc7ILaZRfyHB
NVOFBkpdn627G190
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIGCDCCA/CgAwIBAgIQKy5u6tl1NmwUim7bo3yMBzANBgkqhkiG9w0BAQwFADCB
...
lBlGGSW4gNfL1IYoakRwJiNiqZ+Gb7+6kHDSVneFeO/qJakXzlByjAA6quPbYzSf
+AZxAeKCINT+b72x
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIFdDCCBFygAwIBAgIQJ2buVutJ846r13Ci/ITeIjANBgkqhkiG9w0BAQwFADBv
...
PUsE2JOAWVrgQSQdso8VYFhH2+9uRv0V9dlfmrPb2LjkQLPNlzmuhbsdjrzch5vR
pu/xO28QOG8=
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIENjCCAx6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBvMQswCQYDVQQGEwJTRTEU
...
mnkPIAou1Z5jJh5VkpTYghdae9C8x49OhgQ=
-----END CERTIFICATE-----
</ca>

Titel: Re: Certificaat, en automatisch starten
Bericht door: Briolet op 05 januari 2019, 14:07:07
Het certificaat staat dus in het bestand.

Dan is het de OpenVPN client op je telefoon die niet weet hoe hij daar mee moet omgaan.  Volgens mij zien op dit forum wel instructies geplaatst hoe je OpenVPN op je telefoon moet instellen.

Ik snap alleen niet waarom er in jouw bestand 4 certificaten staan. Ik heb er maar 1 in staan. En je kunt in dsm ook maar 1 certificaat aan OpenVPN koppelen.

Wel jammer dat het readme bestand van synology alleen instructies voor Windows/Mac/Linux bevat en niet voor Android/iOS
Titel: Re: Certificaat, en automatisch starten
Bericht door: Birdy op 05 januari 2019, 15:35:55
Ik draai OpenVPN op m'n Synology Router en mijn VPNConfig.ovpn (export) zie er standaard zo uit:

dev tun
tls-client

remote YOUR_SERVER_IP 1194

# The "float" tells OpenVPN to accept authenticated packets from any address,
# not only the address which was specified in the --remote option.
# This is useful when you are connecting to a peer which holds a dynamic address
# such as a dial-in user or DHCP client.
# (Please refer to the manual of OpenVPN for more information.)

#float

# If redirect-gateway is enabled, the client will redirect it's
# default network gateway through the VPN.
# It means the VPN connection will firstly connect to the VPN Server
# and then to the internet.
# (Please refer to the manual of OpenVPN for more information.)

#redirect-gateway def1

# dhcp-option DNS: To set primary domain name server address.
# Repeat this option to set secondary DNS server addresses.

#dhcp-option DNS DNS_IP_ADDRESS

pull

# If you want to connect by Server's IPv6 address, you should use
# "proto udp6" in UDP mode or "proto tcp6-client" in TCP mode
proto udp

script-security 2


reneg-sec 0

auth SHA512

cipher AES-256-CBC

auth-user-pass


key-direction 1

comp-lzo
explicit-exit-notify
<ca>

-----BEGIN CERTIFICATE-----
MIIEJTCCAw2gAwIBAgIJAPjRCKWBZspaMA0GCSqGSIb3DQEBCwUAMIGUMQswCQYD
ENZ................................
-----END CERTIFICATE-----
</ca>

<tls-auth>

#
# 2048 bit OpenVPN static key
#
-----BEGIN OpenVPN Static key V1-----
0f05094d83d651ebe19e23104a3db8da
ENZ................................
-----END OpenVPN Static key V1-----
</tls-auth>

Deze heb ik geïmporteerd (na wat aanpassingen) op m'n Android app "OpenVPN voor Android"
Titel: Re: Certificaat, en automatisch starten
Bericht door: SiJoNas op 05 januari 2019, 16:21:27
Nou, voor het certificaat probleem heb ik een oplossing: voeg setenv CLIENT_CERT 0 toe aan het .ovpn bestand - en dat werkt! Wat daarvan de gevolgen zijn voor bijv. de encryptie, zoek ik nog wel eens uit maar vooralsnog ben ik geholpen.

Oplossing komt hier vandaan: klik hier (https://www.synology-forum.nl/index.php?topic=16937.msg100724#msg100724)

Blijft nu nog open: het automatisch starten......
Titel: Re: Certificaat, en automatisch starten
Bericht door: Briolet op 05 januari 2019, 16:39:40
…Wat daarvan de gevolgen zijn voor bijv. de encryptie, zoek ik nog wel eens uit…

Maakt volgens mij niets uit. Ik lees:
Citaat van: link (https://forums.openvpn.net/viewtopic.php?t=11991)
This is necessary to resolve an ambiguity when the profile contains no client certificate or key, because otherwise the client app can't know whether an external certificate/key pair should be obtained from the Keychain, or whether the server actually doesn't require a client certificate/key. The option is given as a "setenv" to avoid breaking other OpenVPN clients that might not recognize it.
Het heeft alleen eenduidig aan dat je dat certificaat niet gebruikt.