{"id":15902931,"url":"https://github.com/erikh/go-transport","last_synced_at":"2025-04-02T20:14:16.018Z","repository":{"id":144200541,"uuid":"253816977","full_name":"erikh/go-transport","owner":"erikh","description":"trivial client/server tls auth transport framework","archived":false,"fork":false,"pushed_at":"2020-04-10T19:16:38.000Z","size":28,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-08T10:42:44.728Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/erikh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-07T14:24:47.000Z","updated_at":"2021-08-26T21:38:09.000Z","dependencies_parsed_at":"2023-06-17T18:34:37.278Z","dependency_job_id":null,"html_url":"https://github.com/erikh/go-transport","commit_stats":{"total_commits":25,"total_committers":1,"mean_commits":25.0,"dds":0.0,"last_synced_commit":"549e370f2408f60354ccb112b9af45455dc54fbf"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erikh%2Fgo-transport","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erikh%2Fgo-transport/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erikh%2Fgo-transport/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erikh%2Fgo-transport/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erikh","download_url":"https://codeload.github.com/erikh/go-transport/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246884767,"owners_count":20849554,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-06T12:00:38.706Z","updated_at":"2025-04-02T20:14:15.999Z","avatar_url":"https://github.com/erikh.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## go-transport: easy-to-use TLS-backed transports for cert auth scenarios\n\n[![Build Status](https://travis-ci.org/erikh/go-transport.svg?branch=master)](https://travis-ci.org/erikh/go-transport) [![GoDoc](https://godoc.org/github.com/erikh/go-transport?status.svg)](https://godoc.org/github.com/erikh/go-transport)\n\ngo-transport implements basic TLS-backed transports. These transports can\ncreate both clients and servers that can auth via client cert; and if the cert\nis omitted, they will magically transform into plain connections. Be careful\nwith nil pointers! The goal is to provide safe, common functionality from the\ncrypto/tls, net/http and net packages based on modern practices for secure\nconnectivity at the cost of the flexibility these packages provide.\n\ntransport includes HTTP and TCP functionality, as well as a certificate\nutility framework that sits on top of most of the crypto, pki and x509\npackages.\n\nAdditionally, it resolves CRLs in a meaningful way at the time of connect, if a\nCRL is provided.\n\nPlease note that there are many constraints in the system as of now:\n\n- largely only situations where client certs are needed is where this library\n  excels; I hope to change that in the future but this is my current\n  use-case... So until that changes, this library will likely not grow much.\n- RSA, ECDSA, PKCS#1 and PKCS#8 PEM are the only supported key formats.\n- You must use a CA that can be verified; this means that self-signed certs\n  are largely out. Build a real CA instead.\n\n## Example\n\n```go\n// you need to generate a CA and certs first. to generate certs you can use our\n// example certgen program:\n//\n// go install -tags nobuild github.com/erikh/go-transport/certgen/...\n//\n// Then execute the following commands in the same dir as this source code:\n//\n// certgen -ca -out-cert ca.crt -out-key ca.key\n// certgen -sign-cert ca.crt -sign-key ca.key --host localhost -out-cert server.crt -out-key server.key\n// certgen -sign-cert ca.crt -sign-key ca.key -client --host localhost -out-cert client.crt -out-key client.key\n//\npackage main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"net/http\"\n\n\ttransport \"github.com/erikh/go-transport\"\n)\n\ntype successHandler struct{}\n\nfunc (h *successHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tio.WriteString(w, \"hello from go-transport\")\n}\n\nfunc main() {\n\tcert, err := transport.LoadCert(\"ca.crt\", \"server.crt\", \"server.key\", \"\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tclientCert, err := transport.LoadCert(\"ca.crt\", \"client.crt\", \"client.key\", \"\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tserver, err := transport.NewHTTP(cert)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tclient, err := transport.NewHTTP(clientCert)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\ts, l, err := server.Server(\"localhost:8000\", \u0026successHandler{})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tgo s.Serve(l)\n\tdefer l.Close()\n\n\tresp, err := client.Client(nil).Get(\"https://localhost:8000\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tif resp.StatusCode != 200 {\n\t\tpanic(resp.Status)\n\t}\n\n\tcontent, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(string(content))\n}\n```\n\n## Future Plans\n\n- Websockets\n- Server side only TLS\n\n## License\n\nCopyright (c) 2018-2020 Erik Hollensbe\n\nMIT License\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n## Author\n\nErik Hollensbe \u003ch-e@hollensbe.org\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferikh%2Fgo-transport","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferikh%2Fgo-transport","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferikh%2Fgo-transport/lists"}