-
Notifications
You must be signed in to change notification settings - Fork 331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
T6486: T6379: Rewrite generate openvpn client-config #3747
Conversation
👍 |
❌ VyOS CLI smoketests failed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are lots of very necessary updates and good ideas here, but I think if we are at it, we can make the script a lot better by integrating it with the pki
subtree and converting it to the new-style op mode.
parser.add_argument("-a", "--ca", type=str, help='OpenVPN CA cerificate', required=True) | ||
parser.add_argument("-c", "--cert", type=str, help='OpenVPN client cerificate', required=True) | ||
parser.add_argument("-k", "--key", type=str, help='OpenVPN client cerificate key', action="store") | ||
parser.add_argument( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason not to convert this scripts to the new-style op mode? I think people may want to retrieve OpenVPN client configs through the API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script is not ideal.
For example, if the server listen address is not set, which address should be on the client site (x.x.x.x/None/'replace me')?
For now, it generates x.x.x.x
, which is not the address. This is not a good solution for the API where all data must be actual, but if it is OK, we can probably overwrite it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should add an argument like strict: book
. If it's true, then any incomplete config will result in an exception vyos.opmode.DataUnavailable
. If it's false, then the script will output a placeholder, maybe as a commented-out line.
# listen-address is missing from the config
# To make this config usable, add "remote <server address> option, like:
# remote openvpn.example.net
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is more bug fix.
Can we merge it as it is and refactor it if required in the separate PR?
help='OpenVPN interface the client is connecting to', | ||
required=True, | ||
) | ||
parser.add_argument( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those options were more or less direct translations from my really old script that I wrote for use outside of VyOS and then crudely ported to VyOS. At the time explicit options used to make sense, sort of, because certs and keys were stored in files.
But now they are stored in the config, so I think we should remove the explicit CA option and just fetch it from the pki
entry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we get them from PKI as completion helper, we do not use this script directly as separate file
it generates from the command
vyos@vyos# run generate openvpn client-config interface vtun20 ca openvpn-ca certificate openvpn-client
Where openvpn-ca and openvpn-client are certificate names from the PKI path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point is, the interface already defines which CA to use. There is no reason to ask the user for it separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, the tls ca
is multi-value
vyos@r4# show interfaces openvpn vtun20 tls ca-certificate
ca-certificate ca
+ca-certificate cb
+ca-certificate cc
+ca-certificate cd
[edit]
vyos@r4#
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if clients should also allow all the same CAs in that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be behavior change and should be processed by a separate PR
If I understand correctly, your goal is replacing CLI op-mode to provide client-cert
only as an arg
I.e Before:
generate openvpn client-config interface vtun20 ca openvpn-ca certificate openvpn-client
After:
generate openvpn client-config interface vtun20 certificate openvpn-client
This way all CA's will be included from pki ca
based on the vtunX
configuration
Do we really need it? If yes, it is better to do it in a separate PR
I never used several CA's for a client. Even in theory is it possible to sign a client cert by several CA's?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does client mode support multiple CAs? If there are multiple CAs in an organiazation, I suppose the assumption is that the server cert can also be signed with any of them, and thus the client may need to verify the server cert against multiple CAs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's fix bugs without new options.
The original bugs https://vyos.dev/T6486 and https://vyos.dev/T6379
And both should solved in this change.
This command helps to generate users `.ovpn` files Rewrite `generate openvpn client-config` to use Config() It needs to get the default values as `ConfigTreeQuery` is not supporting default values. Fixed "ignores configured protocol type" if TCP is used Fixed lzo, was used even if lzo not configured Fixed encryption is not parse the dict
CI integration 👍 passed! Details
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, let's merge it for the fixes first and figure out the rest later.
@Mergifyio backport circinus sagitta |
✅ Backports have been created
|
Change Summary
This command helps to generate users
.ovpn
files Rewritegenerate openvpn client-config
to use Config() It needs to get the default values asConfigTreeQuery
is not supporting default values.Fixed "ignores configured protocol type" if TCP is used
Fixed lzo, was used even if lzo was not configured
Fixed encryption does not parse the dict
Types of changes
Related Task(s)
Related PR(s)
Component(s) name
openvpn
Proposed changes
How to test
Configure Openvpn in TCP mode,
Before the fix the proto is UDP, but expected TCP
Generated OpenVPN client config file
After the fix the protocol is correct, encyption with correct maps, lzo not exists:
Smoketest result
Checklist: