PKey.ReadFromFile
-----------------

Reads a key from a PEM file.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Certificates](component_Certificates.md) | [11.4](newinversion114.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "PKey.ReadFromFile"; Path { ; Password } ) 

**MBS**( **"PKey.ReadFromFile";** /\* Reads a key from a PEM file. \*/  
**$Path**; /\* The native file path to the PEM file.e.g. "/Users/cs/Desktop/test.pem" \*/   
**$Password**) /\* Optional; For encrypted private keys, the password to use.e.g. "test" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Path | The native file path to the PEM file. | "/Users/cs/Desktop/test.pem" |  |
| Password | For encrypted private keys, the password to use. | "test" | Optional |

### Result

Returns PKey reference number or error.

### Description

Reads a key from a PEM file.  
Format can be either text PEM format or binary DER format.  
  
This function requires a native path. Use [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md) to convert a FileMaker path to a native path if required. If you like to have the user choose the path, you can use [FileDialog](component_FileDialog.md) functions.  
For Server be aware that server has limited permissions and may not be able to access all files on a computer.  
### See also

- [Encryption.PubKeyEncrypt](EncryptionPubKeyEncrypt.md)
- [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md)
- [PKCS12.ReadFromFile](PKCS12ReadFromFile.md)
- [PKCS7.ReadFromFile](PKCS7ReadFromFile.md)
- [PKey.Read](PKeyRead.md)
- [X509.ReadFromFile](X509ReadFromFile.md)

### Release notes

- **Version 11.4**
    - Added [PKey.Read](https://www.mbsplugins.eu/PKeyRead.shtml), [PKey.ReadFromContainer](https://www.mbsplugins.eu/PKeyReadFromContainer.shtml) and [PKey.ReadFromFile](https://www.mbsplugins.eu/PKeyReadFromFile.shtml) functions.

### Blog Entries

- [New in MBS FileMaker Plugin 11.4](https://www.mbsplugins.de/archive/2021-09-15/New_in_MBS_FileMaker_Plugin_11/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 11.4pr3](https://www.mbsplugins.de/archive/2021-08-25/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 22nd August 2021 , last changed 3th March 2025

  
[PKey.ReadFromContainer](PKeyReadFromContainer.md) - [PKey.Release](PKeyRelease.md)

[HTML Version](PKeyReadFromFile.shtml)