Skip to content
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

CLI options for SSL/TLS #122

Open
noraj opened this issue Sep 3, 2023 · 3 comments
Open

CLI options for SSL/TLS #122

noraj opened this issue Sep 3, 2023 · 3 comments

Comments

@noraj
Copy link
Contributor

noraj commented Sep 3, 2023

It would be nice to add CLI options for ssl_cert and ssl_key

@ohler55
Copy link
Owner

ohler55 commented Sep 4, 2023

Seems reasonable. I'll add those on the next release.

@ohler55
Copy link
Owner

ohler55 commented Sep 25, 2023

Please try the "in-a-bind" branch. I have not tested the options yet but they should work.

@noraj
Copy link
Contributor Author

noraj commented Sep 27, 2023

In the doc (https://www.rubydoc.info/gems/agoo/2.15.7/Agoo/Server#init-class_method) is not written what format of key/cert is expected?

For example PEM format is crashing agoo:

➜ agoo --ssl_cert /tmp/localhost.crt --ssl_key /tmp/localhost-privateKey.key 
  Running /tmp/localhost.crt
/home/noraj/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/agoo-2.15.7/bin/agoo:217:in `load': --> /tmp/localhost.crt
syntax error, unexpected `BEGIN'
>  1  -----BEGIN CERTIFICATE-----
>  2  MIIDhDCCAmygAwIBAgIEd1OWoDANBgkqhkiG9w0BAQsFADBbMScwJQYDVQQDDB5SZWdlcnkgU2Vs
>  3  Zi1TaWduZWQgQ2VydGlmaWNhdGUxIzAhBgNVBAoMGlJlZ2VyeSwgaHR0cHM6Ly9yZWdlcnkuY29t
>  4  MQswCQYDVQQGEwJVQTAgFw0yMzA5MjcwMDAwMDBaGA8yMTIzMDkyNzE3NTY0MFowRjESMBAGA1UE
>  5  AwwJbG9jYWxob3N0MSMwIQYDVQQKDBpSZWdlcnksIGh0dHBzOi8vcmVnZXJ5LmNvbTELMAkGA1UE
>  6  BhMCVUEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDFvg8GmEMgYOPvRnqOAqclj5Qy
>  7  a+vMjLtc6cXS9Aj5Wub3xkLF51HrOsxmZeb0sJQQ4PraLva5loP+PmO91IKkwZqo0ul6YMskZbsc
>  8  cjYvqnK4L43EWVqwBp6W/fmr6FlhBVkNF5KS7YSxMFKx8mp4Hs0BMkSTNLolMjWeOSLLXx7V+POl
>  9  ezupYQJDyLsCRotzzxSSe7+Lb1kwMLTHhpgt/BJ1ws8GTRhXW4GOpB2jzuuZbOX8zMR8u5IGALaL
> 10  XxGkmGBcuo0Y/sxPaIT4c3wNBAcwLSgz+eLgu1bk/ROtteo/FtMemwyJLVRP33oqRnfo/9zhkh0b
> 11  WjwIZof92chRAgMBAAGjYzBhMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1Ud
> 12  DgQWBBQSUU4GTP6YLc/dzoCapxYvz3vxoTAfBgNVHSMEGDAWgBQSUU4GTP6YLc/dzoCapxYvz3vx
> 13  oTANBgkqhkiG9w0BAQsFAAOCAQEAC1mXqOze906c/5Y5X2TUGid3HO/FNcvk9L7Ojk1WYsdavRU9
> 14  o9Il7uthAcP7mKwswkxkwTivNJNQapqa4OtbalSIa5BvpG9bTtIOtfrNPqwY7lXkCnwNskOrpHgP
> 15  ibXNW1lRjXaNNQIYvGBF1tH15lI3ZGXm1zZXQiiZ1vH2hOWoK3ewxoXutVE3LOnsz9Yi5LgSGMyl
> 16  XW6dTfx3VbdpMR8d3hy7Y/OP5P/s50gIYnC7CLwuW36XLsjMIoD4mUjRvW20afWXYgvv9XBcnlE0
> 17  tvAa8QNvnK+6mFo0hdg4SY1/g7Hm2KlCLgCeLQ9MkY2VhQ9GpWRYhJS58SLL1rwafQ==
> 18  -----END CERTIFICATE-----
/tmp/localhost.crt:1: syntax error, unexpected `BEGIN' (SyntaxError)
-----BEGIN CERTIFICATE-----
     ^~~~~

        from /home/noraj/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/agoo-2.15.7/bin/agoo:217:in `<top (required)>'
        from /home/noraj/.asdf/installs/ruby/3.2.2/bin/agoo:25:in `load'
        from /home/noraj/.asdf/installs/ruby/3.2.2/bin/agoo:25:in `<main>'
➜ file /tmp/localhost.crt       
/tmp/localhost.crt: PEM certificate

➜ file /tmp/localhost-privateKey.key                  
/tmp/localhost-privateKey.key: PEM RSA private key

That's weird because it works with the lib:

irb(main):006:0> Agoo::Server.init(6464, 'root', bind: 'https://127.0.0.1:4343', ssl_cert: '/tmp/localhost.crt', ssl_key: '/tmp/localhost-privateKey.key')
=> nil
irb(main):007:0> Agoo::Server.start()
I 2023/09/27 20:10:49.813474256 INFO: Agoo 2.15.7 with pid 40016 is listening on http://:6464.
I 2023/09/27 20:10:49.813484856 INFO: Agoo 2.15.7 with pid 40016 is listening on https://127.0.0.1:4343.

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

No branches or pull requests

2 participants