Skip to content

add example mTLS + proxy mode#40

Merged
jxx-gg merged 4 commits intomasterfrom
exmaple
Sep 15, 2021
Merged

add example mTLS + proxy mode#40
jxx-gg merged 4 commits intomasterfrom
exmaple

Conversation

@jxx-gg
Copy link
Copy Markdown
Contributor

@jxx-gg jxx-gg commented Sep 10, 2021

  • The example includes 3 binaries, server, target and client.
    • server: it only serves as a proxy, and it doesn't create new sessions.
    • target: it registers at the server, and wait for incoming connections. If a supported incoming connection is received, it dials a pre-specified address.
    • client: it registers at the server, and tries to dial at the [dialTarget, dialTargetType]. Once a tunnel session is established (via server) to the target, it will connect the tunnel session to the local stdIO. This can be used with ssh's ProxyCommand option (see comments in the client.go for an example command).
  • The example included two target type SSH and gNMI.
  • mTLS support is also added.

@jxx-gg jxx-gg requested a review from gcsl September 10, 2021 15:22
// --dial_target=target1 \
// --dial_target_type=SSH" $USER@localhost
// mTLS:
// ssh -o ProxyCommand="client
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whitespace to be consistent with above TLS example.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines +58 to +60
certFile = flag.String("cert_file", "", "The certificate file location")
keyFile = flag.String("key_file", "", "The private key file location")
caFile = flag.String("ca_file", "", "The CA file location (for mTLS). If provided, it will be handled as mTLS")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a TLS expert, so I may be getting something wrong here, but these options are a bit confusing:
In the TLS case -cert_file is used to specify the CA to verify the server.
In the mTLS case -ca_file is used to specify the CA to verify the server, and -cert_file, -key_file are used to specify the client's certificate and key.

What would be more clear is for the -ca_file to always be used to specify the CA to verify the server. You enable mTLS by passing in cert_file, key_file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. Updated.

… side when cert file or key file are not provided
dialTargetType = flag.String("dial_target_type", "", "The type of target protocol, e.g. GNMI or SSH.")
certFile = flag.String("cert_file", "", "The certificate file location. If both cert_file and key_file are provided, mTLS will be used.")
keyFile = flag.String("key_file", "", "The private key file location. If both cert_file and key_file are provided, mTLS will be used.")
caFile = flag.String("ca_file", "", "The CA file location (for mTLS)")
Copy link
Copy Markdown

@aaronbee aaronbee Sep 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The help message for ca_file should not include "(for mTLS)"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@jxx-gg jxx-gg merged commit 41267ed into master Sep 15, 2021
@jxx-gg jxx-gg deleted the exmaple branch September 15, 2021 14:29
@jxx-gg jxx-gg restored the exmaple branch September 27, 2021 15:21
@jxx-gg jxx-gg deleted the exmaple branch September 27, 2021 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants