-
Notifications
You must be signed in to change notification settings - Fork 67
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
feat: support acme ssl certificates #636
base: main
Are you sure you want to change the base?
feat: support acme ssl certificates #636
Conversation
7616856
to
a456bd0
Compare
That's great! I immediately see a few things I want to clarify and try to fix. So I have a suggestion for you: will you have the energy to test and finalize the interaction with ACME next week? |
@vaerh sure thing, happy to help! |
@heuels |
Hi! |
@vaerh to be honest that feels like giving too much responsibility to this module. I think that the user should be the one responsible for opening the port (by inserting a firewall rule), making sure that the Consider the use-case when the company is running their own on-premises ACME server. The module could not possibly know which interfaces should |
@heuels |
Hi @heuels , I need your help.
|
@vaerh I will check these today and report back 🫡 |
|
Thanks for the info! When implementing timeouts for ipsec I encountered the unpleasant thing that the REST session timeout is only 60 seconds. Always. Can you check if the new resource will work? |
@heuels |
@vaerh apologies, bit of a hectic week. I will have time to test this on Monday 🙏🏻 |
"challenge_type": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
ForceNew: true, | ||
Description: "ACME challenge.", | ||
ValidateFunc: validation.StringInSlice([]string{"cloud-dns", "http-01"}, false), | ||
DiffSuppressFunc: AlwaysPresentNotUserProvided, | ||
}, |
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 don't think RouterOS supports DNS challenge?
Here is a full list of supported parameters: https://help.mikrotik.com/docs/spaces/ROS/pages/2555969/Certificates#Certificates-Serverproperties
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 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.
Huh, interesting!
@vaerh I tried a couple of times, and the module execution consistently failed for me, however the certificate every time was successfully created. Here is an example execution log: $ tofu apply
╷
│ Warning: Provider development overrides are in effect
│
│ The following provider development overrides are set in the CLI configuration:
│ - terraform-routeros/routeros in ~/Projects/terraform-provider-routeros
│
│ The behavior may therefore not match any released version of the provider and applying changes may cause the
│ state to become incompatible with published releases.
╵
OpenTofu used the selected providers to generate the following execution plan. Resource actions are indicated
with the following symbols:
+ create
OpenTofu will perform the following actions:
# module.example_letsencrypt.routeros_system_certificate_acme.letsencrypt will be created
+ resource "routeros_system_certificate_acme" "letsencrypt" {
+ akid = (known after apply)
+ common_name = (known after apply)
+ country = (known after apply)
+ crl = (known after apply)
+ days_valid = (known after apply)
+ digest_algorithm = (known after apply)
+ directory_url = "https://acme-staging-v02.api.letsencrypt.org/directory"
+ dns_name = "gw1.example.com"
+ expired = (known after apply)
+ expires_after = (known after apply)
+ fingerprint = (known after apply)
+ id = (known after apply)
+ invalid_after = (known after apply)
+ invalid_before = (known after apply)
+ issued = (known after apply)
+ issuer = (known after apply)
+ key_size = (known after apply)
+ key_type = (known after apply)
+ key_usage = (known after apply)
+ locality = (known after apply)
+ name = (known after apply)
+ organization = (known after apply)
+ private_key = (known after apply)
+ serial_number = (known after apply)
+ skid = (known after apply)
+ state = (known after apply)
+ subject_alt_name = (known after apply)
+ trusted = (known after apply)
+ unit = (known after apply)
}
Plan: 1 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
OpenTofu will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
module.example_letsencrypt.routeros_system_certificate_acme.letsencrypt: Creating...
module.example_letsencrypt.routeros_system_certificate_acme.letsencrypt: Still creating... [10s elapsed]
module.example_letsencrypt.routeros_system_certificate_acme.letsencrypt: Still creating... [20s elapsed]
module.example_letsencrypt.routeros_system_certificate_acme.letsencrypt: Still creating... [30s elapsed]
module.example_letsencrypt.routeros_system_certificate_acme.letsencrypt: Still creating... [40s elapsed]
╷
│ Error: resource no longer exists
│
│ with module.example_letsencrypt.routeros_system_certificate_acme.letsencrypt,
│ on ../_modules/example_letsencrypt/main.tf line 12, in resource "routeros_system_certificate_acme" "letsencrypt":
│ 12: resource "routeros_system_certificate_acme" "letsencrypt" {
│
╵
|
Yeah, that's a problem. I can't verify the work with LE. Can you run the execution with environment variables |
Interesting sausage chain coming in :) I'm taking some time to figure it out. |
I experimented on my local ACME and got the same result. In principle, we can try to process it, although we won't be able to use the code that is used to wait for containers to start and stop. |
A stab at #88 🙌🏻
I've made changes to the
routeros_system_certificate
provider to support requesting a new ACME certificate.I'm not very fluent at Go, so any and all comments are very appreciated!
Prerequisites
common_name
.www
service enabled.Limitations
common_name
.name
andcommon_name
must both be present in the resource and must match, because when using ACME,name
is generated and always equals tocommon_name
.apply
once to addacme_ssl_certificate {}
block to it.Examples
Example with Let's Encypt:
Example with Let's Encypt Staging: