Where does the word “Cocksure” come from and What does Cocksure mean?

The great Oxford English Dictionary waxes facetious about the word cocksure.

It says, in effect, this should mean “as sure as a cock,” that is, “as secure, safe, certain, trustworthy, reliable, etc.,” as a cock.

But what kind of cock? Certainly not a rooster.

So, the dictionary suggests, possibly the reference, four and a half centuries ago, “may have been to the security or certainty of the action of a cock or tap in preventing the escape of liquor, or perhaps of a cock with a removable turning-key in leaving the contents of a tun secure from interference.”