Mali also beat Ghana in the same playoff match at the last edition in Equatorial Guinea and Gabon a year ago.
Samassa put his team in front in the 21st minute with a diving header following a good pass from Adama Tamboura on the left.
Man of the match Keita made it 2-0 just after halftime, the midfielder ghosting into the penalty area to convert a cross by Ousmane Coulibaly.
Ghana wasted a chance to get back in the match when Salif Coulibaly handled in the box and Mubarak Wakaso blazed his 58th-minute penalty high over the bar.
Wakaso had previously converted three spot kicks at the tournament.
Ghana eventually pulled one back when Kwadwo Asamoah beat goalkeeper Soumbeyla Diakite with a long-range drive in the 82nd minute.
Then, as Ghana pushed forward in search of an equaliser, Mali caught them on the counter attack with Diarra scoring three minute into stoppage time.
Nigeria meet Burkina Faso in Sunday's final in Johannesburg.