Updating WebDAV SSL Certificate via API

curtii

Dabbler
Joined
Jul 29, 2016
Messages
32
Hello, and thanks in advance for any help.

I have LetsEncrypt certificates for the web UI working great, thanks to danb35's script.

Recently, the LetsEncrypt certificate renewal fired, and it got automatically applied to the web GUI just like it should. What I found out recently once the previous certificate expired is that the WebDAV service that uses the same certificate is not getting updated (This makes perfect sense, as it is not covered in the renewal script). I was able to manually go into the WebDAV service settings and fix the issue, but would like to try automating that as well.

The main part I'm having trouble with is finding where in the API I would be able to modify this - The closest I've gotten is that I found the WebDAV general settings in the API, but it doesn't seem to be where the certificate is set - https://myfreenashostname.net/api/v1.0/services/webdav/ contains the following:

Code:
{"id": 1, "webdav_htauth": "digest", "webdav_password": "mysupertopsecretpassword", "webdav_protocol": "https", "webdav_tcpport": 8080, "webdav_tcpportssl": 8443}


Is there a good way in general to figure out where a setting inside the GUI lives in the API? Once I have that figured out, I think I would be all set - From there, it's just a matter of adding a second block inside my script, similar to the first but that updates the WebDAV certificate.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
I guess one way around this would be to use a different one of my scripts to set up Nextcloud (including its SSL certificate), and then use Nextcloud as your WebDAV system. Probably not the most elegant, though.

I understand that as a general rule, if you can set something in the web GUI, there should be an API endpoint to change it. Since you can select the certificate in the GUI, it seems worth continuing to look in the API, but I also don't see anything documented there. I'd probably submit this as a bug against the API, and if it turns out it is there, it becomes a bug against the docs.
 

curtii

Dabbler
Joined
Jul 29, 2016
Messages
32
I'm actually pretty inclined to take your advice on Nextcloud - I actually already have a Nextcloud server up and running, and it's already got LetsEncrypt working - Not sure why I didn't think to just do it that way in the first place xD

I'll also probably make a submission regarding the API documentation as you suggested - Would definitely be good to see that functionality, and to have it in the documentation.
 

curtii

Dabbler
Joined
Jul 29, 2016
Messages
32
I took a brief look at doing it via NextCloud, that's definitely an option but I would like to pursue getting this API functionality to work inside of FreeNAS directly. I took danb35's advice, and opened a bug report here. I referenced this thread in the description for that bug as well. Once there's a fix, I'll post it here as well for anyone in the future who may find themselves in this situation as well.
 
Top