the package only helps to setup a special tls listener to be used with
the http server, as shown in the example. the http handler code and
routing is not affected in any way and is completely independent.

the special listener uses a ca cert to generate new server certs every
time you reach under a new name. client only need to trust the ca cert
at one time. if they connect to the server the listener returns the
existing server cert or creates a new cert (with the self signed ca
cert) that includes the name or ip it was called with.

hope that helps

On 6/28/22 16:03, Hugh Myrie wrote:
Hi Martin,

How does localca handle CORS?

Originally I defined an handler and pass it as a parameter to ListenAndServeTLS

c := cors.New(cors.Options{
         AllowedOrigins:   []string{"*"},
         AllowedMethods:   []string{"GET", "PUT", "POST", "DELETE"},
         AllowedHeaders:   []string{"*"},
         AllowCredentials: true,
     })
handler := c.Handler(r)

On Tue, Jun 28, 2022 at 7:03 AM Hugh Myrie <hugh.my...@gmail.com <mailto:hugh.my...@gmail.com>> wrote:

    Thanks Martin for your help.

    On Tue, Jun 28, 2022, 06:26 Martin Schnabel <m...@mb0.org
    <mailto:m...@mb0.org>> wrote:

        hi hugh,

        i played around with the same idea six years ago, resulting in
        https://github.com/mb0/localca <https://github.com/mb0/localca>

        it will use a self signed root cerificate and creates new child
        certificates specific to the requested hostname, be it an ip or
        a name
        like my_local.box

        i haven't tested it for awhile, but the idea does apply.

        have fun

        On 6/28/22 02:35, Hugh Myrie wrote:
         > I wish to create a secure private network using a self-signed
         > certificate with a Go web server: See the following code block:
         >
         > // Code
         >      err := http.ListenAndServeTLS(":"+port, "auto.org.pem",
         > "auto.org-key.pem", handler)
         >      if err != nil {
         >
         >          logError((err.Error()))
         >          log.Fatal("ListenAndServe: ", err)
         >      }
         > // End of Code
         >
         > Could I auto  generate (and register) the .pem and .key files
        using GO?
         > I wish to create a trust certificate if there files do not exist.
         >
         > I came across the following website:
         >
         >
        "https://gist.github.com/shaneutt/5e1995295cff6721c89a71d13a71c251
        <https://gist.github.com/shaneutt/5e1995295cff6721c89a71d13a71c251>"
         >
         > I am not sure how to implement this. Your help is appreciated.
         >
         > --
         > You received this message because you are subscribed to the
        Google
         > Groups "golang-nuts" group.
         > To unsubscribe from this group and stop receiving emails from
        it, send
         > an email to golang-nuts+unsubscr...@googlegroups.com
        <mailto:golang-nuts%2bunsubscr...@googlegroups.com>
         > <mailto:golang-nuts+unsubscr...@googlegroups.com
        <mailto:golang-nuts%2bunsubscr...@googlegroups.com>>.
         > To view this discussion on the web visit
         >
        
https://groups.google.com/d/msgid/golang-nuts/6ce2a407-600d-44b7-97d1-53e90e91e7c8n%40googlegroups.com
        
<https://groups.google.com/d/msgid/golang-nuts/6ce2a407-600d-44b7-97d1-53e90e91e7c8n%40googlegroups.com>

         >
        
<https://groups.google.com/d/msgid/golang-nuts/6ce2a407-600d-44b7-97d1-53e90e91e7c8n%40googlegroups.com?utm_medium=email&utm_source=footer
        
<https://groups.google.com/d/msgid/golang-nuts/6ce2a407-600d-44b7-97d1-53e90e91e7c8n%40googlegroups.com?utm_medium=email&utm_source=footer>>.

-- You received this message because you are subscribed to a topic
        in the Google Groups "golang-nuts" group.
        To unsubscribe from this topic, visit
        https://groups.google.com/d/topic/golang-nuts/0XKZ3AkAA9w/unsubscribe
        <https://groups.google.com/d/topic/golang-nuts/0XKZ3AkAA9w/unsubscribe>.
        To unsubscribe from this group and all its topics, send an email
        to golang-nuts+unsubscr...@googlegroups.com
        <mailto:golang-nuts%2bunsubscr...@googlegroups.com>.
        To view this discussion on the web visit
        
https://groups.google.com/d/msgid/golang-nuts/63b7a250-5afc-6171-6526-00796498ea36%40mb0.org
        
<https://groups.google.com/d/msgid/golang-nuts/63b7a250-5afc-6171-6526-00796498ea36%40mb0.org>.



--
http://www.jaxtr.com/blessed_hope <http://www.jaxtr.com/blessed_hope>

--
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/2c4546e6-22b7-302b-311b-d6f4e198c60a%40mb0.org.

Reply via email to