Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 96ff6fd

Browse files
committed
incorporated code review feedback 8/16
1 parent ce1976a commit 96ff6fd

2 files changed

Lines changed: 7 additions & 31 deletions

File tree

README.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -335,18 +335,17 @@ Signed: false
335335
Loaded Time: Mon, 14 Aug 2017 22:25:16 PDT
336336
```
337337
338-
##### Error One
338+
Notice that only GRPC plugins are supported. There is also a requirement to use trusted CA and providing both plugin-cert and plugin-key. Below common error messages are presented that you might receive if one of those requirements are not fulfilled.
339+
340+
##### Case 1: Missing plugin key
339341
340342
```sh
341343
▶ snaptel plugin load --plugin-cert=snaptest-srv.crt --plugin-ca-certs=snaptest-ca.crt ../snap-plugin-lib-go/rand-collector
342344
Error: Both plugin certification and key are mandatory.
343345
Usage: load <plugin_path> [--plugin-cert=<plugin_cert_path> --plugin-key=<plugin_key_path> --plugin-ca-certs=<ca_cert_paths>]
344346
```
345347
346-
> What happened: Both `plugin-cert` and `plugin-key` are mandatory.
347-
348-
349-
##### Error Two
348+
##### Case 2: Using untrusted CA
350349
351350
```sh
352351
▶ snaptel plugin load --plugin-cert=snaptest-srv.crt --plugin-key=snaptest-srv.key --plugin-ca-certs=snaptest-ca.crt ../snap-plugin-lib-go/rand-collector
@@ -355,15 +354,11 @@ Usage: load <plugin_path> [--plugin-cert=<plugin_cert_path> --plugin-key=<plugin
355354
356355
```
357356
358-
> What happened: Did you start `snapteld` with CA cert or put the trusted CA in your OS/APP trust store?
359-
360-
##### Error Three
357+
##### Case 3: Trying to set TLS GRPC communication for non-GRPC plugin
361358
362359
```sh
363360
▶ snaptel plugin load --plugin-cert snaptest-srv.crt --plugin-key snaptest-srv.key --plugin-ca-certs snaptest-ca.crt ../snap/snap-plugin-collector-mock1
364361
Error: secure framework can't connect to insecure plugin; plugin_name: mock
365362
Usage: load <plugin_path> [--plugin-cert=<plugin_cert_path> --plugin-key=<plugin_key_path> --plugin-ca-certs=<ca_cert_paths>]
366363
```
367364
368-
>What happened: The TLS is only supported for GRPC plugins. Restarting `snapteld` without TLS to load non-GRPC plugins.
369-

snaptel/common.go

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"encoding/json"
2424
"fmt"
2525
"io/ioutil"
26-
"strings"
2726

2827
"golang.org/x/crypto/ssh/terminal"
2928

@@ -130,6 +129,8 @@ func getErrorDetail(err error, ctx *cli.Context) error {
130129
return newUsageError(fmt.Sprintf("%v", err.(*plugins.GetPluginConfigItemBadRequest).Payload.ErrorMessage), ctx)
131130
case *plugins.GetPluginConfigItemUnauthorized:
132131
return newUsageError(fmt.Sprintf("%v", err.(*plugins.GetPluginConfigItemUnauthorized).Payload.Message), ctx)
132+
case *plugins.LoadPluginDefault:
133+
return newUsageError(fmt.Sprintf("%v", err.(*plugins.LoadPluginDefault).Message), ctx)
133134
case *tasks.GetTaskNotFound:
134135
return newUsageError(fmt.Sprintf("%v", err.(*tasks.GetTaskNotFound).Payload.ErrorMessage), ctx)
135136
case *tasks.GetTaskUnauthorized:
@@ -149,10 +150,6 @@ func getErrorDetail(err error, ctx *cli.Context) error {
149150
case *tasks.UpdateTaskStateUnauthorized:
150151
return newUsageError(fmt.Sprintf("%v", err.(*tasks.UpdateTaskStateUnauthorized).Payload.Message), ctx)
151152
default:
152-
// this is a hack
153-
if strings.Contains(err.Error(), "tls: oversized record") || strings.Contains(err.Error(), "malformed HTTP response") {
154-
return newUsageError(extractError(err.Error()), ctx)
155-
}
156153
return newUsageError(fmt.Sprintf("Error: %v", err), ctx)
157154
}
158155
}
@@ -221,19 +218,3 @@ func BasicAuth(ctx *cli.Context) runtime.ClientAuthInfoWriter {
221218
}
222219
return nil
223220
}
224-
225-
// extractError is a hack for SSL/TLS handshake error.
226-
func extractError(m string) string {
227-
ts := strings.Split(m, "\"")
228-
229-
var tss []string
230-
if len(ts) > 0 {
231-
tss = strings.Split(ts[0], "malformed")
232-
}
233-
234-
errMsg := "Error connecting to API. Do you have an http/https mismatching API request?"
235-
if len(tss) > 0 {
236-
errMsg = tss[0] + errMsg
237-
}
238-
return errMsg
239-
}

0 commit comments

Comments
 (0)