Skip to content

Conversation

@okraits
Copy link
Member

@okraits okraits commented May 12, 2025

Fixes #349

Checklist

  • I have read the OpenWISP Contributing Guidelines.
  • I have manually tested the changes proposed in this pull request.
  • I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • I have updated the documentation.

Reference to Existing Issue

Closes #349.

Description of Changes

Made the parameter tls_cipher an array and updated the documentation accordingly. There were no tests to update.

@coveralls
Copy link

coveralls commented May 12, 2025

Coverage Status

coverage: 99.179% (+0.001%) from 99.178%
when pulling d2077a6 on tls-cipher-list
into 777ddfb on master.

Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@okraits this change would be backward incompatible. Why is it needed?

Can you provide an example of a value that you can't supply now and you'd be able to supply with the list format?

@okraits
Copy link
Member Author

okraits commented May 12, 2025

@okraits this change would be backward incompatible. Why is it needed?

Can you provide an example of a value that you can't supply now and you'd be able to supply with the list format?

I gave an example and the reasoning in the related issue.

Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about avoiding the schema change and change the code internally to convert the string to a list with 1 element so that it's rendered as a list?

Is the problem just the rendering of UCI option vs UCI list?
Or do we actually need to allow multiple lines with different values?

@okraits
Copy link
Member Author

okraits commented May 15, 2025

What about avoiding the schema change and change the code internally to convert the string to a list with 1 element so that it's rendered as a list?

I think this would be an appropriate solution as well.

Is the problem just the rendering of UCI option vs UCI list? Or do we actually need to allow multiple lines with different values?

Rendering the parameter as an UCI list is required for the parameter to work. In the LuCI OpenVPN app it's possible to create multiple list items with different values but I think for most usecases of netjsonconfig it would be sufficient to have one list item.

@nemesifier
Copy link
Member

What about avoiding the schema change and change the code internally to convert the string to a list with 1 element so that it's rendered as a list?

I think this would be an appropriate solution as well.

We can do this here:
https://github.com/openwisp/netjsonconfig/blob/master/netjsonconfig/backends/openwrt/converters/openvpn.py

We need two tests:

  • classic conversion to NetJSON to UCI, probably modifying existing tests is going to be enough
  • backward conversion from UCI to NetJSON, not sure if we can modify an existing one or we need to add a new one

Is the problem just the rendering of UCI option vs UCI list? Or do we actually need to allow multiple lines with different values?

Rendering the parameter as an UCI list is required for the parameter to work. In the LuCI OpenVPN app it's possible to create multiple list items with different values but I think for most usecases of netjsonconfig it would be sufficient to have one list item.

Ok so it sounds to methat handling this internally it's the best option as it's just an output issue.

@okraits
Copy link
Member Author

okraits commented Oct 31, 2025

@nemesifier I implemented the change as suggested. Do you think we need more or other tests?

@okraits
Copy link
Member Author

okraits commented Nov 10, 2025

@nemesifier Any opinion on this?

Copy link
Member

@pandafy pandafy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your patience @okraits.

It took me some time to understand the working of the tls_cipher setting in OpenVPN, hence the delay.

vpn["name"] = vpn.pop(".name")
del vpn[".type"]
if (cipher := vpn.get("tls_cipher")) and isinstance(cipher, list) and cipher:
vpn["tls_cipher"] = cipher[0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it is possible to have more than one cipher suite present in tls_cipher, it may be possible that there are more than 1 item in the list.

I think we should combine all the items in the list to one string instead of just using the first one.

Comment on lines +18 to +19
if (cipher := vpn.get("tls_cipher")) and isinstance(cipher, str):
vpn["tls_cipher"] = [cipher]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, we will need to split the value in tls_cipher with :, but we will need to ensure that :@SECLEVEL should stay intact.

E.g.:

TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256:TLS-DHE-RSA-WITH-AES-256-CBC-SHA:@SECLEVEL=0

should become

  • TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256
  • TLS-DHE-RSA-WITH-AES-256-CBC-SHA:@SECLEVEL=0

"script_security": 1,
"status": "/var/log/openvpn.status 30",
"status_version": 1,
"tls_cipher": "TLS-DHE-RSA-WITH-AES-256-CBC-SHA:@SECLEVEL=0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to update this test to have multiple ciphers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] tls_cipher should be an array and not a string

5 participants