class Cfssl < Formula desc "CloudFlare's PKI toolkit" homepage "https://cfssl.org/" url "https://github.com/cloudflare/cfssl/archive/v1.4.0.tar.gz" sha256 "d8b74a162d71fff92626622962e123fd4cc693efb90b71116c1e61fa8dde41fd" head "https://github.com/cloudflare/cfssl.git" bottle do cellar :any_skip_relocation sha256 "5ea762e6bb069bc75f27de5f6792922a1815f7f03dca506b2e53d8e4bbf85cc1" => :catalina sha256 "df8bd563a4dd4ca5db514c6db898d2253163903f5bf490cbf1ab300584222590" => :mojave sha256 "e0ab7384cefb5f374308610b3f388efc4af2ce9f524ee5e79143ccbe392f9582" => :high_sierra end depends_on "go" => :build depends_on "libtool" def install ENV["GOPATH"] = buildpath cfsslpath = buildpath/"src/github.com/cloudflare/cfssl" cfsslpath.install Dir["{*,.git}"] cd "src/github.com/cloudflare/cfssl" do system "go", "build", "-o", "#{bin}/cfssl", "cmd/cfssl/cfssl.go" system "go", "build", "-o", "#{bin}/cfssljson", "cmd/cfssljson/cfssljson.go" system "go", "build", "-o", "#{bin}/cfsslmkbundle", "cmd/mkbundle/mkbundle.go" end end def caveats; <<~EOS `mkbundle` has been installed as `cfsslmkbundle` to avoid conflict with Mono and other tools that ship the same executable. EOS end test do (testpath/"request.json").write <<~EOS { "CN" : "Your Certificate Authority", "hosts" : [], "key" : { "algo" : "rsa", "size" : 4096 }, "names" : [ { "C" : "US", "ST" : "Your State", "L" : "Your City", "O" : "Your Organization", "OU" : "Your Certificate Authority" } ] } EOS shell_output("#{bin}/cfssl genkey -initca request.json > response.json") response = JSON.parse(File.read(testpath/"response.json")) assert_match(/^-----BEGIN CERTIFICATE-----.*/, response["cert"]) assert_match(/.*-----END CERTIFICATE-----$/, response["cert"]) assert_match(/^-----BEGIN RSA PRIVATE KEY-----.*/, response["key"]) assert_match(/.*-----END RSA PRIVATE KEY-----$/, response["key"]) end end