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

fix: removed println debugging calls + removed unnecessary test #1

Merged
merged 4 commits into from
Oct 18, 2024
Merged
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
5 changes: 4 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ on:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# ssl-inspector
# SSL Inspector

A small helpful portable program to test SSL connections.
6 changes: 3 additions & 3 deletions ssl-inspector.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2024-present Paul Horton (@madpah)
* Copyright (c) 2024-present Sonatype Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -123,9 +123,9 @@ func checkSSL(endpoint string) (bool, []string, error) {
var certValidationError *tls.CertificateVerificationError
var netUrlError *url.Error
if errors.As(err, &netUrlError) {
println("url.Error")
//println("url.Error")
if errors.As(netUrlError.Err, &certValidationError) {
println("tls.CertificateVerificationError")
//println("tls.CertificateVerificationError")
handled := false
if hostnameError, ok := certValidationError.Err.(x509.HostnameError); ok {
messages = append(messages, fmt.Sprintf("Certifcate for %s is not valid for %s", hostnameError.Certificate.Subject, endpoint))
Expand Down
36 changes: 20 additions & 16 deletions ssl-inspector_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2024-present Paul Horton (@madpah)
* Copyright (c) 2024-present Sonatype Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,6 +17,7 @@
package main

import (
"runtime"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -65,24 +66,27 @@ func TestCheckSSL(t *testing.T) {
assert.False(t, valid)
})

t.Run("revokedAndTrustedByOS", func(t *testing.T) {
valid, messages, err := checkSSL("https://revoked.badssl.com")
assert.NoError(t, err)
assert.Equal(t, 1, len(messages))
assert.False(t, valid)
})
}

func TestSingleCert(t *testing.T) {
valid, messages, err := checkSSL("https://revoked.badssl.com")
assert.NoError(t, err)
assert.Equal(t, 1, len(messages))
for _, m := range messages {
println(m)
if runtime.GOOS != "linux" {
// Looks like Linux does not do realtime CRL checks - at least on Ubuntu
t.Run("revokedAndTrustedByOS", func(t *testing.T) {
valid, messages, err := checkSSL("https://revoked.badssl.com")
assert.NoError(t, err)
assert.Equal(t, 1, len(messages))
assert.False(t, valid)
})
}
assert.False(t, valid)
}

// func TestSingleCert(t *testing.T) {
// valid, messages, err := checkSSL("https://revoked.badssl.com")
// assert.NoError(t, err)
// assert.Equal(t, 1, len(messages))
// for _, m := range messages {
// println(m)
// }
// assert.False(t, valid)
// }

func TestParseEndpoints(t *testing.T) {
t.Run("httpsNoPortSpecified", func(t *testing.T) {
domain, err := validateEndpoint("https://badssl.com")
Expand Down
Loading