m365 login [options]
Allow to login with a .pfx certificate that doesn't require a password.
Unsure how this would be achieved (for now), just believe this should be possible.
I believe we should be able to use a .pfx certificate that doesn't have a password (this is the case when fetching a base64 encoded certificate from Azure Key Vault). Currently, when you don't use the --password option CLI assumes a .pem file is passed in to the --certificateFile option. Naturally, this doesn't achieve the wanted result.
Additionally, you cannot pass in an empty password to the --password option. This always results in errors.
Thanks for the suggestion. By itself, it's pretty odd though. PFX is secured by password so why would you want to use it without a password?
There is no rule that a .pfx needs to be protected by a password. When you export a .pfx certificate from Azure KeyVault, it doesn鈥檛 have a password. When you make a .pfx from a base64 encoded string, it doesn鈥檛 necessarily have a password.
Even if you export a .pfx from the Windows Certificate Store you don鈥檛 HAVE to provide a password.
It would make CLI support certificates like this, even if we consider it bad form 馃檪
Right, so the recommendation is to protect your .pfx with a password because it contains a private key, but it's not necessary. Good catch! We should definitely update CLI to not require password.
I'll take this one too, if you want. This can be the preparation to cleanly allow #1971 to be implemented.
Approach:
Sounds good?
Sounds like a plan! Appreciate your help! 馃憦
I didn't like my plan anymore, thinking of how to implement this one so we could easily also implement #1971 .
Current approach:
It's not the cleanest of code but I cannot figure out how to determine if a base64 encoded string is a pem or a pfx without doing the actual conversion and letting it throw the exception if it isn't pem.
Also, I figured it isn't worse than the current solution since that assumes PEM when --password is not provided with no fallback.
I get it might be difficult to follow along without seeing the actual code. It's more for future reference: as an answer to why the implementation differs from what has been discussed.
I get it might be difficult to follow along without seeing the actual code.
Feel free to submit a draft PR and lets discuss 馃槉馃憤馃徎
@garrytrinder The PR is waiting for you 馃槈