Unless you bought a painting directly from an artist, and you have a certificate of authenticity made by him, or a bill of sale or a paper showing the artwork is a gift to you from the artist, it is in my opinion impossible to have a 100 % certitude that the painting you buy is authentic.
If you buy an artwork with a Certificate of authenticity:
1- have this certificate updated at the time you buy or re-sell the painting
a/ an expert may change his opinion about a painting. I saw a Parisian expert for Eugene Boudin changing his opinion about a painting he authenticated 30 years earlier and that he inventoried in his catalogue raisonne. b/the certificate you have has been made by Mr. X, but today Mr. X past away and is replaced by Mr. Y. Mr. Y may or may not renew the certificate of authenticity. c/ you need to be sure that the painting has the appropriate certificate: By example for a painting by Amedeo Modigliani. You need to have a certificate of authenticity made by Ceroni , only 337 paintings have been admitted as authentic by Mr. Ceroni. The problem is our expert past away .. You have other very important experts on Modigliani's work, Parisot, Restellini, etc By example if you have a painting with the COA from Christian Parisot, who is a very charming man, and a great historian, you will have it very difficult to have it sold because he was accused of making fake Modigliani works etc ..see links here under. Restellini ( ex secretary of Christian Parisot !) abandoned the writing of the catalogue raisonne he started since he received death treats ... yes fine art has his" Dark side" very dark... http://www.independent.co.uk/arts-entertainment/art/news/modigliani-expert-accused-of-being-arts-biggest-fraud-8463883.html
2- Does the certificate of authenticity made by a gallery 100 % reliable?
a/ if the certificate is made by a gallery of very high standing, they will have the certificate of authenticity made by the sole recognized painter. Often these galleries were exhibiting the artist in the past. Those galleries are of course reliable but I will always ask the original certificate since several scandals made surface recently and especially one of the oldest gallery in the USA, the Knoedler Gallery in NY: http://www.nytimes.com/2015/10/12/arts/design/lawsuits-in-knoedler-forgery-case-are-set-for-trial.html
b/ if the certificate is made by a gallery but is not considered as one of the top 25 galleries in the world, just consider that this certificate is completely useless.
You always should request the original updated certificate by the sole recognized authenticator and submit your buy to the contingency of providing this certificate if they don't want to have the sale canceled.