Home
About
Search
Welcome to M-Files Empower – our new support experience. We'd love to hear what you think!Give feedback
Home

M-Files - Automatic Renewal of TLS Certificate for gRPC connections

Last updated on 2 June 2026

COM API

Overview

TLS certificates for gRPC connections of M-Files Desktop and M-Files Admin may need to be updated regularly, especially if you are using short-lived or automatically renewed certificates. This article explains how certificate renewal works in M-Files and what options are available if you want to automate the update process in a self-hosted environment.

In M-Files Cloud, you do not need to manage TLS certificates because M-Files handles them as part of the cloud service.

Details

You can configure a TLS certificate in M-Files Admin through the Manage Server Certificate option. This certificate is mostly used for gRPC connections in M-Files Desktop and M-Files Admin. Depending on your environment, the same certificate may also be used to secure Web and Mobile client connections.

Starting from M-Files version 26.6, you can update an existing certificate programmatically by using the API method SetTLSCertificate from the ServerManagementOperations object.

Requirements to use the API

  • You have a self-hosted environment. This capability does not apply to M-Files Cloud (M-Files maintains the TLS certificate in the cloud service).
  • Your M-Files Server version is 26.6 (June 2026) or later.
  • You have familiarity with using the M-Files COM API.
  • You are a system administrator in M-Files.
  • You already have set up a TLS certificate at least once via M-Files Admin.
  • You have a certificate that M-Files can use, see this document for details: Generating a TLS Certificate for Self-Hosted M-Files.

API Example

The API method is in the ServerManagementOperations namespace of a ServerApplication and is called SetTLSCertificate. It takes three arguments:

  1. The Key ciphertext as string
  2. The Certificate ciphertext as string
  3. Empty string

The following sample PowerShell script shows the gist of how to use this method. 

Note that:

  • You may need to adapt it to use case - for example, alter credentials and login method if you will not always run it as the current local sysadmin account.
  • M-Files standard support does not cover assistance with implementing or adapting scripts and API calls.

Example of executing the script, assuming it is saved in the current folder with the name "Set-MFilesTlsCertificate.ps1".

C:\certs\Set-MFilesTlsCertificate.ps1 -CertificatePath "C:\certs\mfilesserver.crt" -KeyPath "C:\certs\mfilesserver.key"

The example script itself:

param(

   [Parameter(Mandatory=$true)]

   [string]$CertificatePath,

   [Parameter(Mandatory=$true)]

   [string]$KeyPath

)

$ErrorActionPreference = 'Stop'

try {

    if( -not (Test-Path -LiteralPath $CertificatePath) ) {

        throw "Certificate file not found: $CertificatePath"

    }

    if( -not (Test-Path -LiteralPath $KeyPath) ) {

        throw "Private key file not found: $KeyPath"

    }

    $cert = Get-Content -Raw -LiteralPath $CertificatePath

    $key  = Get-Content -Raw -LiteralPath $KeyPath

    $server = New-Object -ComObject MFilesAPI.MFilesServerApplication

    # Local gRPC endpoint: protocol "grpc-local", empty endpoint = current M-Files version,

    # MFAuthTypeLoggedOnWindowsUser (=1) reuses the logged-on Windows identity (admin rights required).

    $null = $server.ConnectAdministrative(

        $null,           # TimeZone

        1,               # MFAuthTypeLoggedOnWindowsUser

       [System.Reflection.Missing]::Value, # UserName

       [System.Reflection.Missing]::Value, # Password

       [System.Reflection.Missing]::Value, # Domain

       "grpc-local",    # ProtocolSequence

       "localhost",     # NetworkAddress

       "",              # Endpoint (empty for local gRPC)

       "" )             # LocalComputerName

# The actual API call is here, after you have the ServerApplication initialized

    $sMgmtOps = $server.ServerManagementOperations

   $sMgmtOps.SetTLSCertificate($key, $cert, "")

    $null = $server.Disconnect()

    Write-Output "SUCCESS"

}

catch {

    Write-Output "FAILURE"

    Write-Output ""

    Write-Output "Error message:"

    Write-Output $_.Exception.ToString()

    Write-Output ""

    Write-Output "Script stack trace:"

    Write-Output $_.ScriptStackTrace

    exit 1

}

Still need help?