In "The Fellowship of the Ring," when explaining the story of the Ring to Frodo, Gandalf says, "I wondered often how Gollum came by a Great Ring, as plainly it was -- that at least was clear from the first."
Gandalf doesn't explain his reasoning, but he is definitely claiming to have known...