The journey of Han Solo from Imperial Officer to Rebel Alliance general was a long and interesting one. He did attend the Imperial Academy at Carida, and graduated at the top of his class with the rank of Lieutenant. As told in the Hutt Gambit,
Han also had numerous run-ins with the Alliance prior to the events of Episode IV (some of which are detailed in the video game Empire at War.
So this was one of the reasons he was clearly uneasy about getting involved in the Alliance during Episode IV. One other reason was that he was double-crossed by the Alliance in another mission, detailed in the novel Rebel Dawn:
As he became closer to the Alliance, he eventually was responsible for the creation of Renegade Squadron, a smuggler-based Rebel espionage unit (appearing in video and card games). By the time of Episode VI, Han was solidly on the side of the Rebels, and when the bounty on his head was lifted by Jabba's death, he was able to devote his time to the cause.
Solo was likely influenced by a former lover, Bria Tharen, who he rescued from slavery. Bria died at the Battle of Toprawa fighting for the Rebellion. Of course, the influence of Leia was a much larger factor.