Kenya?s police chief Joseph Boinnet says the men are in ?good health but traumatised?, AFP news agency reports.
The officers were taken in an attack by the Islamist militants in north-eastern Garissa county in May 2013, close to the border with Somalia.
The Somalia-based group killed 148 people in an attack on Kenya?s Garissa University College in April.
The officers were released on 25 June, but news of the operation was only made public on Thursday.
The two men were taken across the border to Somalia where they were repeatedly moved between different al-Shabab camps, AFP cites Mr Boinnet as saying.
He gave no details of how the men were freed, but thanked the ?several security agencies which undertook this delicate rescue mission?.
An al-Shabab spokesman quoted in pro-al-Shabab media said the officers were released because they had converted to Islam.
The al-Qaeda-linked group group has carried out numerous attacks in Kenya near the long porous border with Somalia.
It says it is at war with Kenya, and wants it to withdraw troops sent to Somalia in 2011 to help the weak government in Mogadishu fight the militants.