cli-microsoft365: Bug report: unable to login using certificate
Priority
(Medium) I’m annoyed but I’ll live
Description
When trying to login to CLI for Microsoft 365 using a certificate file, an error is thrown.
Steps to reproduce
- Create Entra ID app registration with certificate authentication
- Generate a certificate
- Run
m365 login --authType certificate --certificateFile <path to file> --appId <app ID> --password <password> --tenant <tenant ID>
Expected results
CLI should read the certificate and retrieve a token.
Actual results
Error: Unparsed DER bytes remain after ASN.1 parsing.
Diagnostics
CLI for Microsoft 365 version
v7.4.0
nodejs version
v20.10.0
Operating system (environment)
Windows
Shell
PowerShell
cli doctor
No response
Additional Info
The certificate is definitely valid. I can log in using the base64 string of the certificate. I’m also able to log in using the certificate with password in PnP.PowerShell. It seems like something goes wrong when trying to read the certificate.
About this issue
- Original URL
- State: closed
- Created 5 months ago
- Reactions: 1
- Comments: 17 (17 by maintainers)
I’m using
2.3.0.Just created a new certificate using the same command/options. This certificate works. Strange! The old certificate is still not working, yet I can authenticate with that one using PnP.PowerShell. Since a new certificate works, I think we can close this issue 🤷 Thanks!
Could very well be the certificate format @milanholemans. I use this script for it and it works all the time:
It creates the cert, exports it to the current folder and removes it from the cert store.