<p>Hopefully someone can point me in the right direction. I am able to use both of these packages stand alone, but can't find a way to use them together.</p>
<p>The 2 packages are:</p>
<p>github.com/julienschmidt/httprouter</p>
<p>and</p>
<p>github.com/rsc/letsencrypt</p>
<p>I'm sure there must be a simple way to do it, but I can't seem to figure it out.</p>
<hr/>**评论:**<br/><br/>captncraig: <pre><p>I actually prefer running my go apps binding to plain http, and then use <a href="https://caddyserver.com" rel="nofollow">caddy</a> to magically get LE certs and proxy to my backend.</p></pre>inanotherworld: <pre><p>Doing it this way actually has a lot of side benefits I hadn't considered - thanks!</p></pre>pschlump: <pre><p>The Go package <a href="https://github.com/xenolf/lego" rel="nofollow">https://github.com/xenolf/lego</a> has all the code in it for getting back and updating the Let's Encrypt .key and .crt files. There is a command line main as a nice example and a library. You set up a go routine that runs once every X days to update the .key/.crt files. Then periodically you re-load the server. This can be done cleanly with <a href="https://github.com/fvbock/endless" rel="nofollow">https://github.com/fvbock/endless</a>.</p></pre>tehbmar: <pre><p>You can use letsencrypt to create your key and crt files then pull them into Go with ListenAndServerTLS()</p>
<p>To get the .key and .crt file you will need to run Let's Encrypt in manual mode
Docs here:
<a href="https://letsencrypt.readthedocs.io/en/latest/using.html#manual" rel="nofollow">https://letsencrypt.readthedocs.io/en/latest/using.html#manual</a></p>
<p>GoLang Example With TLS:
<a href="https://gist.github.com/denji/12b3a568f092ab951456" rel="nofollow">https://gist.github.com/denji/12b3a568f092ab951456</a></p></pre>inanotherworld: <pre><p>Yes I have done it that way before. But I was hoping to use Russ's package - github.com/rsc/letsencrypt</p></pre>Sphax: <pre><p>I believe <a href="https://play.golang.org/p/ZnZoIFgANJ" rel="nofollow">this</a> should work.
Add the proper imports obviously.</p></pre>kardianos: <pre><p>I think if you use <a href="https://godoc.org/golang.org/x/crypto/acme/autocert" rel="nofollow">https://godoc.org/golang.org/x/crypto/acme/autocert</a> it uses an SNI challenge rather then a route based challenge. But I suspect it will work with httprouter. The package isn't finished yet nor is the API considered stable, but work is progressing on it.</p></pre>gohacker: <pre><p>I'm looking for something like this:</p>
<pre><code>package main
import (
"net/http"
"example.org/letsencrypt"
)
func main() {
// Register all your handlers as usual.
http.HandleFunc("/", indexHandler)
.....
// The following command should register the /.well-known/acme-challenge/ handler,
// get the certs if they aren't there or are outdated,
// start a goroutine for updating the certs every two or three weeks,
// and finally call http.ListenAndServeTLS.
letsencrypt.ListenAndServe(":443", nil)
}
</code></pre>
<p>Is there anything similar?</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传