Hi!
Both of the sentences above are correct. But according to the rule of using the potential form of a verb, the object is indicated by が . You can replace を in the first sentence with が and you'll get the same meaning. It's OK to use を too, but in several situations, it may make the sentence unnatural. So it doesn't always work. For example:
私は日本語が出来る。OK!
私は日本語を出来る。Unnatural