BLE secure connection

I am developing application that supposed to connect to another device using BLE.

I am wondering if there is a way I can programatically establish secure connection with a peripheral device Or is it solely OS responsibilty?


In Android, this can be done using something like https://stackoverflow.com/questions/38055699/programmatically-pairing-with-a-ble-device-on-android-4-4