URL-safe base64 encoding for keys
Hi,
With my CloudStack integration I'm running into a problem with the cephx keys due to '/' being possible in the cephx keys.
CloudStack's API expects a URI to be passed when adding a storage pool, e.g.:
addStoragePool?uri=rbd://user:[email protected]/poolname
If 'cephxkey' contains a / the URI parser in Java fails (java.net.URI) and splits the URI in the wrong place.
For base64 there is a specification [0] that describes the usage of - and _ instead of + and /
Is there a way that we change the bits in src/common/armor.c and replace the + and / for - and _?
Thanks,
Wido
Quoted 10 lines · Wido den Hollander
Hi,
With my CloudStack integration I'm running into a problem with the cephx keys due to '/' being possible in the cephx keys.
CloudStack's API expects a URI to be passed when adding a storage pool, e.g.:
addStoragePool?uri=rbd://user:[email protected]/poolname
Quoted 8 lines
If 'cephxkey' contains a / the URI parser in Java fails (java.net.URI) and splits the URI in the wrong place.
For base64 there is a specification [0] that describes the usage of - and _ instead of + and /
Is there a way that we change the bits in
src/common/armor.cand replace the
+ and / for - and _?
FWIW (only semi-related), some S3 clients -- s3cmd from s3tools, for example -- seem to choke on the forward slash in radosgw auto-generated secret keys, as well.
Cheers,
Florian
Quoted 17 lines · Florian Haas
Quoted 16 lines · Wido den Hollander
Hi,
With my CloudStack integration I'm running into a problem with the cephx keys due to '/' being possible in the cephx keys.
CloudStack's API expects a URI to be passed when adding a storage pool, e.g.:
addStoragePool?uri=rbd://user:[email protected]/poolname
If 'cephxkey' contains a / the URI parser in Java fails (java.net.URI) and splits the URI in the wrong place.
For base64 there is a specification [0] that describes the usage of - and _ instead of + and /
Quoted 7 lines
Quoted 2 lines
Is there a way that we change the bits in
src/common/armor.cand replace the
+ and / for - and _?FWIW (only semi-related), some S3 clients -- s3cmd from s3tools, for example -- seem to choke on the forward slash in radosgw auto-generated secret keys, as well.
With radosgw we actually switch a while back to use the alternative encoding. If you still have some old access keys, just replace them.
Yehuda
Quoted 7 lines · Wido den Hollander
CloudStack's API expects a URI to be passed when adding a storage pool, e.g.:
addStoragePool?uri=rbd://user:[email protected]/poolname
If 'cephxkey' contains a / the URI parser in Java fails (java.net.URI) and splits the URI in the wrong place.
First, I actually agree with you -- urlsafe b64 just makes sense. We'd have to go through some sort of a transition period, accepting both, perhaps generating old-style, for some time.
Second, have you tried quoting the unsafe characters? / is %2f, + is %2b, % is %25.
Quoted 7 lines · Yehuda Sadeh
Quoted 4 lines
FWIW (only semi-related), some S3 clients -- s3cmd from s3tools, for example -- seem to choke on the forward slash in radosgw auto-generated secret keys, as well.
With radosgw we actually switch a while back to use the alternative encoding. If you still have some old access keys, just replace them.
Is "a while back" after 0.47.3? Because I was definitely keys with "/" from that version.
Cheers,
Florian
Quoted 6 lines · Florian Haas
Quoted 5 lines · Yehuda Sadeh
Quoted 4 lines
FWIW (only semi-related), some S3 clients -- s3cmd from s3tools, for example -- seem to choke on the forward slash in radosgw auto-generated secret keys, as well.
Quoted 6 lines
Quoted 2 lines
With radosgw we actually switch a while back to use the alternative encoding. If you still have some old access keys, just replace them.
Is "a while back" after 0.47.3? Because I was definitely keys with "/" from that version.
There are the access keys and there are the secrets. The access keys are now url safe, the secrets are not.
Yehuda
Quoted 4 lines · Tommi Virtanen
Quoted 3 lines · Wido den Hollander
CloudStack's API expects a URI to be passed when adding a storage pool, e.g.:
Quoted 9 lines
Quoted 4 lines
addStoragePool?uri=rbd://user:[email protected]/poolname
If 'cephxkey' contains a / the URI parser in Java fails (java.net.URI) and splits the URI in the wrong place.
First, I actually agree with you -- urlsafe b64 just makes sense. We'd have to go through some sort of a transition period, accepting both, perhaps generating old-style, for some time.
My thoughts exactly.
Quoted 2 lines
Second, have you tried quoting the unsafe characters? / is %2f, + is %2b, % is %25.
Yes, I have thought about that, but it would mean extra docs in the CloudStack API docs.
Warning: Please URL-encode your cephx secret since it may contain invalid characters
In the WebGUI (which talks to the API) I could do a URL-encode in JavaScript and do the decode again in the CloudStack management server, but it's not what you want.
So yes, that has crossed my mind, but for now I took the easy way out and generated myself a new key which doesn't contain slashes.
Wido
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/1 Generate URL-safe base64 strings for keys.
In reply to Tommi VirtanenBy using this we prevent scenarios where cephx keys are not accepted in various situations.
Replacing the + and / by - and _ we generate URL-safe base64 keys
--- src/common/armor.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
src/common/armor.c +3 -3
@@ -9,7 +9,7 @@* base64 encode/decode. */ -const char *pem_key ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ; +const char *pem_key ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" ;static int encode_bits (int c) {
@@ -24,9 +24,9 @@ static int decode_bits(char c)return c -'a' +26 ;if (c >='0' && c <='9' )return c -'0' +52 ; -if (c =='+' ) +if (c =='+' || c =='-' )return 62 ; -if (c =='/' ) +if (c =='/' || c =='_' )return 63 ;if (c =='=' )return 0 ;/* just non-negative, please */
Signature · 1 line
1.7.9.5
Re: [PATCH] Generate URL-safe base64 strings for keys.
Quoted 6 lines · Wido den Hollander
By using this we prevent scenarios where cephx keys are not accepted in various situations.
Replacing the + and / by - and _ we generate URL-safe base64 keys
Signed-off-by Wido den Hollander <[email protected]>
Do already properly decode URL-sage base64 encoding?
sage
Quoted 38 lines
--- src/common/armor.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)src/common/armor.c +3
-3@@ -9,7 +9,7 @@* base64 encode/decode. */ -const char *pem_key ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ; +const char *pem_key ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" ;static int encode_bits (int c) {@@ -24,9 +24,9 @@ static int decode_bits(char c)return c -'a' +26 ;if (c >='0' && c <='9' )return c -'0' +52 ; -if (c =='+' ) +if (c =='+' || c =='-' )return 62 ; -if (c =='/' ) +if (c =='/' || c =='_' )return 63 ;if (c =='=' )return 0 ;/* just non-negative, please */ Signature · 6 lines
1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] Generate URL-safe base64 strings for keys.
----- Oorspronkelijk bericht -----
Quoted 10 lines · Wido den Hollander
Quoted 6 lines
By using this we prevent scenarios where cephx keys are not accepted in various situations.
Replacing the + and / by - and _ we generate URL-safe base64 keys
Signed-off-by Wido den Hollander <[email protected]>Do already properly decode URL-sage base64 encoding?
Yes, it decodes URL-safe base64 as well.
See the if statements for 62 and 63, + and - are treated equally, just like / and _.
Wido
Quoted 36 lines
sage
Quoted 34 lines
---
src/common/armor.c| 6 +++---1 file changed, 3 insertions(+), 3 deletions(-)src/common/armor.c +1
-1@@ -9,7 +9,7 @@* base64 encode/decode. */ -const char *pem_key ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ; +const char *pem_key ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" ;static int
encode_bits(int c)
{src/common/armor.c +2
-2@@ -24,9 +24,9 @@ static int decode_bits(char c) return c - 'a' + 26; if (c >= '0' && c <= '9') return c - '0' + 52; - if (c == '+') + if (c == '+' || c == '-') return 62; - if (c == '/') + if (c == '/' || c == '_') return 63; if (c == '=')return 0; /* just non-negative, please */
Signature · 1 line
1.7.9.5
Quoted 10 lines
Quoted 6 lines
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] Generate URL-safe base64 strings for keys.
Quoted 8 lines · Wido den Hollander
Quoted 8 lines · Wido den Hollander
Quoted 6 lines
By using this we prevent scenarios where cephx keys are not accepted in various situations.
Replacing the + and / by - and _ we generate URL-safe base64 keys
Signed-off-by Wido den Hollander <[email protected]>
Quoted 7 lines
Quoted 2 lines
Do already properly decode URL-sage base64 encoding?
Yes, it decodes URL-safe base64 as well.
See the if statements for 62 and 63, + and - are treated equally, just like / and _.
Oh, got it. The commit description confused me... I thought this was related encoding only.
I think we should break the encode and decode patches into separate versions, and apply the decode to a stable branch (argonaut) and the encode to the master. That should avoid most problems with a rolling/staggered upgrade...
sage
Quoted 57 lines
Wido
Quoted 36 lines
sage
Quoted 34 lines
---
src/common/armor.c| 6 +++---1 file changed, 3 insertions(+), 3 deletions(-)src/common/armor.c +1
-1@@ -9,7 +9,7 @@* base64 encode/decode. */ -const char *pem_key ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ; +const char *pem_key ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" ;static int
encode_bits(int c)
{src/common/armor.c +2
-2@@ -24,9 +24,9 @@ static int decode_bits(char c) return c - 'a' + 26; if (c >= '0' && c <= '9') return c - '0' + 52; - if (c == '+') + if (c == '+' || c == '-') return 62; - if (c == '/') + if (c == '/' || c == '_') return 63; if (c == '=')return 0; /* just non-negative, please */
Signature · 1 line
1.7.9.5Quoted 10 lines
Quoted 6 lines
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] Generate URL-safe base64 strings for keys.
Quoted 17 lines · Sage Weil
Quoted 8 lines · Wido den Hollander
Quoted 8 lines · Wido den Hollander
Quoted 6 lines
By using this we prevent scenarios where cephx keys are not accepted in various situations.
Replacing the + and / by - and _ we generate URL-safe base64 keys
Signed-off-by Wido den Hollander <[email protected]>Quoted 7 lines
Quoted 2 lines
Do already properly decode URL-sage base64 encoding?
Yes, it decodes URL-safe base64 as well.
See the if statements for 62 and 63, + and - are treated equally, just like / and _.
Quoted 7 lines
Oh, got it. The commit description confused me... I thought this was related encoding only.
I think we should break the encode and decode patches into separate versions, and apply the decode to a stable branch (argonaut) and the encode to the master. That should avoid most problems with a rolling/staggered upgrade...
I just submitted a patch for decoding only.
During some tests I did I found out that libvirt uses GNUlib and won't handle URL-safe base64 encoded keys.
So, as long as Ceph allows them we're good. Users can always replace the + and / in their key knowing it will be accepted by Ceph.
This works for me for now. The exact switch to base64url should be done at a later stage I think.
The RFC on this: http://tools.ietf.org/html/rfc4648#page-7
Wido
Quoted 60 lines
sage
Quoted 56 lines
Wido
Quoted 36 lines
sage
Quoted 34 lines
---
src/common/armor.c| 6 +++---1 file changed, 3 insertions(+), 3 deletions(-)src/common/armor.c +1
-1@@ -9,7 +9,7 @@* base64 encode/decode. */ -const char *pem_key ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ; +const char *pem_key ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" ;static int
encode_bits(int c)
{src/common/armor.c +2
-3@@ -24,9 +24,9 @@ static int decode_bits(char c)return c -'a' +26 ;if (c >='0' && c <='9' )return c -'0' +52 ; -if (c =='+' ) +if (c =='+' || c =='-' )return 62 ; -if (c =='/' ) +if (c =='/' || c =='_' )return 63 ;if (c =='=' )return 0 ;/* just non-negative, please */ --1.7.9.5
Quoted 10 lines
Quoted 6 lines
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Sage Weil
AppliedRe: [PATCH] Generate URL-safe base64 strings for keys.
Quoted 21 lines · Wido den Hollander
Quoted 20 lines · Sage Weil
Quoted 8 lines · Wido den Hollander
Quoted 8 lines · Wido den Hollander
Quoted 6 lines
By using this we prevent scenarios where cephx keys are not accepted in various situations.
Replacing the + and / by - and _ we generate URL-safe base64 keys
Signed-off-by Wido den Hollander <[email protected]>Quoted 7 lines
Quoted 2 lines
Do already properly decode URL-sage base64 encoding?
Yes, it decodes URL-safe base64 as well.
See the if statements for 62 and 63, + and - are treated equally, just like / and _.
Oh, got it. The commit description confused me... I thought this was related encoding only.
Quoted 6 lines
Quoted 4 lines
I think we should break the encode and decode patches into separate versions, and apply the decode to a stable branch (argonaut) and the encode to the master. That should avoid most problems with a rolling/staggered upgrade...
I just submitted a patch for decoding only.
Applied, thanks!
Quoted 10 lines
During some tests I did I found out that libvirt uses GNUlib and won't handle URL-safe base64 encoded keys.
So, as long as Ceph allows them we're good. Users can always replace the + and / in their key knowing it will be accepted by Ceph.
This works for me for now. The exact switch to base64url should be done at a later stage I think.
The RFC on this: http://tools.ietf.org/html/rfc4648#page-7
We could:
- submit a patch for gnulib; someday it'll support it
- kludge the secret generation code in ceph so that it rejects secrets with problematic encoding... :/ (radosgw-admin does something similar with +'s in the s3-style user keys.)
sage
Quoted 70 lines
Wido
Quoted 60 lines
sage
Quoted 56 lines
Wido
Quoted 36 lines
sage
Quoted 34 lines
---
src/common/armor.c| 6 +++---1 file changed, 3 insertions(+), 3 deletions(-)src/common/armor.c +1
-1@@ -9,7 +9,7 @@* base64 encode/decode. */ -const char *pem_key ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ; +const char *pem_key ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" ;static int
encode_bits(int c)
{src/common/armor.c +2
-3@@ -24,9 +24,9 @@ static int decode_bits(char c)return c -'a' +26 ;if (c >='0' && c <='9' )return c -'0' +52 ; -if (c =='+' ) +if (c =='+' || c =='-' )return 62 ; -if (c =='/' ) +if (c =='/' || c =='_' )return 63 ;if (c =='=' )return 0 ;/* just non-negative, please */ --1.7.9.5
Quoted 10 lines
Quoted 6 lines
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] Generate URL-safe base64 strings for keys.
Quoted 37 lines · Sage Weil
Quoted 21 lines · Wido den Hollander
Quoted 20 lines · Sage Weil
Quoted 8 lines · Wido den Hollander
Quoted 8 lines · Wido den Hollander
Quoted 6 lines
By using this we prevent scenarios where cephx keys are not accepted in various situations.
Replacing the + and / by - and _ we generate URL-safe base64 keys
Signed-off-by Wido den Hollander <[email protected]>Quoted 7 lines
Quoted 2 lines
Do already properly decode URL-sage base64 encoding?
Yes, it decodes URL-safe base64 as well.
See the if statements for 62 and 63, + and - are treated equally, just like / and _.
Oh, got it. The commit description confused me... I thought this was related encoding only.
Quoted 6 lines
Quoted 4 lines
I think we should break the encode and decode patches into separate versions, and apply the decode to a stable branch (argonaut) and the encode to the master. That should avoid most problems with a rolling/staggered upgrade...
I just submitted a patch for decoding only.
Applied, thanks!
Quoted 6 lines
During some tests I did I found out that libvirt uses GNUlib and won't handle URL-safe base64 encoded keys.
So, as long as Ceph allows them we're good. Users can always replace the + and / in their key knowing it will be accepted by Ceph.
Quoted 7 lines
Quoted 4 lines
This works for me for now. The exact switch to base64url should be done at a later stage I think.
The RFC on this: http://tools.ietf.org/html/rfc4648#page-7
We could:
- submit a patch for gnulib; someday it'll support it
I already did, but IF they accept anything else than RFC4648 they'll implement a lot of the other format as well. That will be some work.
Quoted 3 lines
- kludge the secret generation code in ceph so that it rejects secrets with problematic encoding... :/ (radosgw-admin does something similar with +'s in the s3-style user keys.)
Seems the easy way out, but it will work though.
Wido
Quoted 75 lines
sage
Quoted 70 lines
Wido
Quoted 60 lines
sage
Quoted 56 lines
Wido
Quoted 36 lines
sage
Quoted 34 lines
---
src/common/armor.c| 6 +++---1 file changed, 3 insertions(+), 3 deletions(-)src/common/armor.c +1
-1@@ -9,7 +9,7 @@* base64 encode/decode. */ -const char *pem_key ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ; +const char *pem_key ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" ;static int
encode_bits(int c)
{src/common/armor.c +2
-3@@ -24,9 +24,9 @@ static int decode_bits(char c)return c -'a' +26 ;if (c >='0' && c <='9' )return c -'0' +52 ; -if (c =='+' ) +if (c =='+' || c =='-' )return 62 ; -if (c =='/' ) +if (c =='/' || c =='_' )return 63 ;if (c =='=' )return 0 ;/* just non-negative, please */ --1.7.9.5
Quoted 10 lines
Quoted 6 lines
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html