Richard Cassidy, 70, was found guilty at the High Court in Glasgow in June of the murder of David Farish, 75, at his home in Tweedbank, Roxburghshire, in February 2016.
Judge Lord Summers described the murder as “particularly brutal”, with 14 stab wounds inflicted on the victim.
Defence lawyer Brian McConnachie QC said the killing was a “moment of madness” but he described the circumstances as “unique”.
Cassidy had been told Mr Farish had sexually abused a woman over a long period. His lawyer said he went to Mr Farish’s home and “befriended” him in the hope of hearing a confession rather than planning to kill him.
Lord Summers said Cassidy showed premeditation on the day of the attack and referred to a social work report that found he had received Special Forces training while in the Army on how to infiltrate groups by befriending them.
No charges had been brought against Mr Farish.
The court heard that, after the murder, Cassidy contacted police and handed himself in.
Mr McConnachie said most people found it “hard to understand” that Cassidy would be capable of murder. The defence lawyer said: “He had never been in trouble in his life before this incident.
“He lived a fulfilling life until what he describes as a moment of madness in February 2016.”
Cassidy is said to be in poor health and has suffered a heart attack and stroke while in custody.
Lord Summers said he took into account Cassidy’s lack of previous convictions and what he had reportedly been told about Mr Farish as he passed a life sentence with a minimum term of 17 years in jail.
Police Scotland described the case as a “particularly heinous murder of a frail, elderly man in his own home”.
Detective Inspector David Pinkney said: “Although this sentence will not reverse his cruel actions, I do hope it will bring some measure of resolution for David’s family.”