Skip to content

Connect-graph: Value cannot be null, Parameter name: certificate #52

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

Closed
ghost opened this issue Nov 13, 2019 · 6 comments
Closed

Connect-graph: Value cannot be null, Parameter name: certificate #52

ghost opened this issue Nov 13, 2019 · 6 comments
Assignees

Comments

@ghost
Copy link

ghost commented Nov 13, 2019

Hi
I'm testing out the msgraph-sdk-powershell and have installed the module. Using powershell 5.1.
I have Registered an App in my Azure and added a certificate that was created based on .\Create-SelfSignedCertificate.ps1 (https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azuread)

When trying to connect I get the following error:

Connect-Graph -ClientId $clientId -TenantId $TenantId -CertificateName "CN=MyCompanyName"

Connect-Graph : Value cannot be null.
Parameter name: certificate
At line:2 char:1
+ Connect-Graph -ClientId $clientId -TenantId $TenantId -CertificateNam ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Connect-Graph], ArgumentNullException
    + FullyQualifiedErrorId : System.ArgumentNullException,Microsoft.Graph.PowerShell.Authentication.Cmdlets.ConnectGraph

I'm doing something wrong:s, but what?

Im able to get information via the app-registration using the
Invoke-RestMethod -Headers $Headers -Uri "https://graph.microsoft.com/v1.0/users/$UserPrincipalName/photo" -Method Get
Which means that the app registration and permissions are ok, perhaps I need to create a certificate another way?

Any tips are welcome!

brgs

Bjørn

@ghost ghost added the ToTriage label Nov 13, 2019
@GSGBen
Copy link

GSGBen commented Nov 20, 2019

I'm getting this as well.

@peombwa
Copy link
Member

peombwa commented Nov 25, 2019

The error indicates that the certificate was not found in cert:\CurrentUser\My, or it may have expired. Could you verify that the certificate is present in cert:\CurrentUser\My by running Get-ChildItem -path "cert:\CurrentUser\My" | Where Subject -EQ "CN=MyCompanyName". If it is present, then check its expiry date by running Get-ChildItem -path "cert:\CurrentUser\My" | Where Subject -EQ "CN=MyCompanyName" | Select Subject, NotAfter, and ensure NotAfter is > today's DateTime.

@peombwa peombwa added question and removed ToTriage labels Nov 25, 2019
@peombwa peombwa self-assigned this Nov 25, 2019
@ghost
Copy link
Author

ghost commented Nov 25, 2019

Hi @peombwa
Im fairly certain that I always put my certificates on cert:\LocalMachine\My ^^.
I shall try it your way!
brgs
Bjørn

@iaragon76
Copy link

I was battling with the same issue, and indeed, I my certificate was in the localmachine, not in the current user. Other thing, I did export the certificate wihout keys, and uploaded in azuread into my app. Finally I got connected.

@milan-mb
Copy link

milan-mb commented Jun 9, 2020

This helped me.. I was clueless on why the cert was failing error "certificate was not found or has expired" No logs were logged in CAPI which corresponds to the cert I am using.. Adding the cert to users store fixed the issue. That explained why it was failing with no cert found.

@ddyett ddyett closed this as completed Jun 9, 2020
@yuhup2edy
Copy link

Trying to connect mg-graph via a certificate returned from my azure key vault. This runs fine locally but when i run it under an automation account, i get an error stating that the certificate has expired or not found. What might be causing this ? I know for sure that the certs are valid and work great when called locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants