You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We currently cannot support multiple deploy keys. You need this, for instance, if you want to push to gh-pages for drdoctr/doctr and also to master of drdoctr/drdoctr.github.io (which we do want to do, to test it). See #190.
You can easily have two different deploy private key files, but the problem is that we encrypt that with a secret encryption key, which is stored in DOCTR_DEPLOY_ENCRYPTION_KEY. That key is generated when doctr configure is run, and is encrypted with the Travis public key.
So we either need to:
Allow multiple encryption keys (like rename the environment variable based on the repo it is encrypted for).
Allow doctr configure to create multiple deploy keys at once, each encrypted with the same encryption key.
I don't like 2 because unlike 1 and 3, if the environment variable leaks, it leaks all deploy keys, whereas with 1 and 3 a single environment variable leaking would only leak one deploy key.
3 would probably be best if environment variables can actually be that long (supposedly they can). That will require some testing.
3 will be better in the long run, but 1 is easier to implement (considering that for either case, we need to continue to support the previous way of doing things).
I want to brood on this for a little bit. I do want to have this fixed before we do any releases, so that the github.io stuff is actually tested. But I also don't want to make a change that we'd want to change later, since we need to support any scheme we implement indefinitely, unless we want to force people to re-configure doctr.
Hey @asmeurer -- just back from traveling and catching up on email. I don't think I understand yet how 1 would work but I'll try to look into it more tomorrow. I think that 3 would also allow us to more easily extend doctr to CircleCI (not sure how big a priority that is).
Agreed on holding off on releases until we're sorted on this.
1 and 3 are similar. 1 would mean having something like DOCTR_DEPLOY_ENCRYPTION_KEY_DRDOCTR_DOCTR and DOCTR_DEPLOY_ENCRYPTION_KEY_DRDOCTR_DRDOCTR_GITHUB_IO and 3 would mean having DOCTR_DEPLOY_KEY_DRDOCTR_DOCTR and DOCTR_DEPLOY_KEY_DRDOCTR_DRDOCTR_GITHUB_IO. In either case we have to figure out some way to put the repo name in the environment variable name (maybe we should just hash it). The difference is that 1 would continue to use the Fernet encryption to encrypt the deploy ssh key and store the encryption key in the environment variable, and 3 would do away with the Fernet encryption and storing of the ssh key in the file and just store the ssh key in the environment variable ("stored in the environment variable" here means "encrypted with the Travis public key and then stored as a secure env var", obviously).
The Fernet encryption is a level of indirection that seems to be unnecessary (I didn't realize at the time that the private ssh key would fit in an environment variable by itself). It also isn't really more secure because the encrypted private ssh key file is publicly available, just sitting there in the git repo, so if the Fernet encryption key (the contents of the DOCTR_DEPLOY_ENCRYPTION_KEY environment variable) were leaked, it would be no different than if the private ssh key itself were leaked. Maybe it's marginally better for a private repo (I can't imagine how you would be able to access a leaked Travis.com environment variable and not have access to the repo, but maybe it could happen).
The indirection also makes things quite confusing as there's three secret encryption keys, the Travis public/private key, the GitHub deploy public/private key, and the Fernet key, when really you only need the first two. The Fernet encryption only seems useful if you need to encrypt something that is too large to fit in an environment variable, and must be stored in a file. I think a deploy ssh key doesn't fit this bill.
I can't tell however if this could be used to provide different values for the same secure variable in different builds. If so, we could just do one build for drdoctr/doctr and one build for drdoctr/drdoctr.github.io. It would suck that you'd have to have separate builds for it, but I think our use-case of doing this is relatively rare (no one else has requested it).
Might punt on this for the next release. Hopefully the .github.io stuff works. Let us know if you have issues. Implementing this would be a bit of work, and there's already a lot of changes since the last release that I want to stabilize first.
Activity
asmeurer commentedon Aug 22, 2017
Or
I don't like 2 because unlike 1 and 3, if the environment variable leaks, it leaks all deploy keys, whereas with 1 and 3 a single environment variable leaking would only leak one deploy key.
3 would probably be best if environment variables can actually be that long (supposedly they can). That will require some testing.
asmeurer commentedon Aug 22, 2017
https://unix.stackexchange.com/questions/336934/raise-128kib-limit-on-environment-variables-in-linux suggests the limit is something like 131072 characters (our deploy_key file is around 4400 characters).
asmeurer commentedon Aug 22, 2017
3 will be better in the long run, but 1 is easier to implement (considering that for either case, we need to continue to support the previous way of doing things).
asmeurer commentedon Aug 22, 2017
I want to brood on this for a little bit. I do want to have this fixed before we do any releases, so that the github.io stuff is actually tested. But I also don't want to make a change that we'd want to change later, since we need to support any scheme we implement indefinitely, unless we want to force people to re-configure doctr.
@gforsyth any thoughts?
@danielballan are you pining for a release or can you still use the git version for the time being?
danielballan commentedon Aug 22, 2017
The git version is fine.
danielballan commentedon Aug 22, 2017
Thanks for giving this so much thought today. :- )
gforsyth commentedon Aug 22, 2017
Hey @asmeurer -- just back from traveling and catching up on email. I don't think I understand yet how 1 would work but I'll try to look into it more tomorrow. I think that 3 would also allow us to more easily extend doctr to CircleCI (not sure how big a priority that is).
Agreed on holding off on releases until we're sorted on this.
asmeurer commentedon Aug 22, 2017
1 and 3 are similar. 1 would mean having something like
DOCTR_DEPLOY_ENCRYPTION_KEY_DRDOCTR_DOCTRandDOCTR_DEPLOY_ENCRYPTION_KEY_DRDOCTR_DRDOCTR_GITHUB_IOand 3 would mean havingDOCTR_DEPLOY_KEY_DRDOCTR_DOCTRandDOCTR_DEPLOY_KEY_DRDOCTR_DRDOCTR_GITHUB_IO. In either case we have to figure out some way to put the repo name in the environment variable name (maybe we should just hash it). The difference is that 1 would continue to use the Fernet encryption to encrypt the deploy ssh key and store the encryption key in the environment variable, and 3 would do away with the Fernet encryption and storing of the ssh key in the file and just store the ssh key in the environment variable ("stored in the environment variable" here means "encrypted with the Travis public key and then stored as a secure env var", obviously).The Fernet encryption is a level of indirection that seems to be unnecessary (I didn't realize at the time that the private ssh key would fit in an environment variable by itself). It also isn't really more secure because the encrypted private ssh key file is publicly available, just sitting there in the git repo, so if the Fernet encryption key (the contents of the
DOCTR_DEPLOY_ENCRYPTION_KEYenvironment variable) were leaked, it would be no different than if the private ssh key itself were leaked. Maybe it's marginally better for a private repo (I can't imagine how you would be able to access a leaked Travis.com environment variable and not have access to the repo, but maybe it could happen).The indirection also makes things quite confusing as there's three secret encryption keys, the Travis public/private key, the GitHub deploy public/private key, and the Fernet key, when really you only need the first two. The Fernet encryption only seems useful if you need to encrypt something that is too large to fit in an environment variable, and must be stored in a file. I think a deploy ssh key doesn't fit this bill.
asmeurer commentedon Sep 1, 2017
Another idea. Travis lets you set a secure environment variable to just one build of a matrix by putting
secureundermatrixinstead ofglobal(see f61ae37, which produces this build matrix: https://travis-ci.org/drdoctr/doctr).I can't tell however if this could be used to provide different values for the same secure variable in different builds. If so, we could just do one build for drdoctr/doctr and one build for drdoctr/drdoctr.github.io. It would suck that you'd have to have separate builds for it, but I think our use-case of doing this is relatively rare (no one else has requested it).
I asked about this here: https://stackoverflow.com/questions/45993334/multiple-values-of-a-secure-encrypted-environment-variable-in-travis-yml
danielballan commentedon Sep 1, 2017
Interesting. That seems like the best idea so far (if different values for the same secure variable are supported).
asmeurer commentedon Sep 8, 2017
Might punt on this for the next release. Hopefully the .github.io stuff works. Let us know if you have issues. Implementing this would be a bit of work, and there's already a lot of changes since the last release that I want to stabilize first.
asmeurer commentedon Nov 20, 2017
Fixed by #280
danielballan commentedon Nov 20, 2017
@asmeurer Heh. I saw your tweet about
os.environ.keys()and figured you might be tackling this.