Skip to content
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

Remove trailing whitespaces from certificates #156

Merged
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
10 changes: 6 additions & 4 deletions src/exporters/certHelpers.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package exporters

import (
"fmt"
"time"

"crypto/x509"
"encoding/base64"
"encoding/pem"
"fmt"
"os"

"software.sslmate.com/src/go-pkcs12"
"strings"
"time"
"unicode"
)

type certMetric struct {
Expand Down Expand Up @@ -96,6 +96,8 @@ func parseAsPEM(certBytes []byte) (bool, []certMetric, error) {
if block == nil {
return false, metrics, fmt.Errorf("Failed to parse as a pem")
}
// Remove trailing whitespaces to prevent possible error in loop
rest = []byte(strings.TrimRightFunc(string(rest), unicode.IsSpace))
blocks = append(blocks, block)
// Export the remaining certificates in the certificate chain
for len(rest) != 0 {
Expand Down
Loading