Skip to content

Make raw PEM cert bundle string public #22

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,9 @@ func CACerts() (*x509.CertPool, error)
CACerts builds an X.509 certificate pool containing the Mozilla CA Certificate
bundle. This can't actually error and always returns successfully with `nil`
as the error. This will be replaced in `v2` to only return the `CertPool`.

```go
func CACertsAsPEM() string
```
CACertsAsPEM returns a string containing the PEM encoded Mozilla CA Certificate
bundle.
10 changes: 8 additions & 2 deletions certifi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions certifi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,10 @@ func TestGetCerts(t *testing.T) {
t.Errorf("Failed to return the certificates.")
}
}

func TestGetCertsAsPEM(t *testing.T) {
pemcerts := CACertsAsPEM()
if len(pemcerts) == 0 {
t.Errorf("Failed to return the certificates as PEM.")
}
}
6 changes: 6 additions & 0 deletions gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,10 @@ func CACerts() (*x509.CertPool, error) {
pool.AppendCertsFromPEM([]byte(pemcerts))
return pool, nil
}

// CACertsAsPEM returns a string containing the PEM encoded
// certificate bundle from {{ .URL }} fetched on {{ .Timestamp }}.
func CACertsAsPEM() string {
return pemcerts
}
`))