-
Notifications
You must be signed in to change notification settings - Fork 4
Add ability to use existing PSK secrets #32
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
Conversation
Signed-off-by: Pranav Gaikwad <pgaikwad@redhat.com>
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: pranavgaikwad The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/cc @JohnStrunk |
For generating the PSK, we should be able to just use: pvc-transfer/transfer/transfer.go Lines 182 to 194 in 2171849
This creates a ~128bit key:
... looking at the rest of the PR now |
PSKsecrets = /etc/stunnel/certs/key | ||
{{ end }} | ||
|
||
[transfer] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like [transfer]
got moved to below the key specification... was this intentional (and ok?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JohnStrunk Yes, the settings will apply to all subsections including the one used for termination. Its kind of a global setting across mutliple transfers
UseTLS: true, | ||
} | ||
if sc.options.Credentials != nil && sc.options.Credentials.Type == CredentialsTypePSK { | ||
fields.UseTLS = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe call this UsePSK
or something? It's still TLS, even w/ the PSK, it's just TLS-PSK instead of using public-key crypto.
stunnelScript := `/bin/stunnel /etc/stunnel/stunnel.conf | ||
# terminate the transport when transfer isn't available | ||
RETRY=0 | ||
while true; do | ||
nc -z localhost %d | ||
rc=$? | ||
if [ $rc -ne 0 ]; then | ||
RETRY=$((RETRY+1)) | ||
else | ||
RETRY=0 | ||
fi | ||
if [ $RETRY -gt 10 ]; then | ||
exit 0 | ||
else | ||
sleep 1 | ||
fi | ||
done | ||
` | ||
stunnelScript = fmt.Sprintf(stunnelScript, s.ConnectPort()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not following the flow...
I assume this goes with the change to foreground = no
. Is the logic here:
- we're putting stunnel in the bg and having the script (main entrypoint) probe the connection's availability
- When it's no longer available, the entrypoint terminates, bringing the container down and killing the background stunnel process since the container terminates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JohnStrunk That's correct.
transport/stunnel/stunnel.go
Outdated
@@ -290,3 +321,18 @@ func markForCleanup(ctx context.Context, c ctrlclient.Client, objKey types.Names | |||
|
|||
return nil | |||
} | |||
|
|||
// GeneratePassword can be used to generate random character string for 24 byte |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
24 --> 32 bytes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JohnStrunk yeah as per Stunnel documentation, stunnel allows either 16 or 32 bytes PSK. I didn't really try giving a 24 bytes value, I can check if its something we want to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem. The comment just says 24, but the implementation is 32.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh okay.
Signed-off-by: Pranav Gaikwad <pgaikwad@redhat.com>
/lgtm |
Signed-off-by: Pranav Gaikwad pgaikwad@redhat.com
Describe what this PR does
_exit
message was read from server logs to exitIs there anything that requires special attention?
~This PR does NOT add support for creating a new PSK when existing is invalid. Creating PSK is not supported in go currently [1]. Users will need to provide their existing PSK in a secret. If not provided, library will default to creating new TLS certs instead. ~
Updated to create a 32 byte long PSK key. Stunnel requires key to be base64 encoded.
Related issues:
[1] golang/go#6379