Conny Miller's hat is called a "Campaign Hat" which can be traced back to the mid-19th century. Although made by many manufacturers, Stetson was a major producer of these hats. Soldiers found the middle crease of their hats to be impractical since it accumulated rain water and they started pushing up the center so it would shed water. Sometime in 1911, the Army adopted this style of hat as "1911 Hat, Service, M1911 (Campaign Hat)". Unofficially it had several names: "lemon squeezer", "mountie hat", "ranger hat", "drill instructor cover", "smokey bear", "the Montana crease", and several others.
Many reviewers have cited Leo Rosten's very short story "The Path Through the Cemetery" as the source of this episode. While this much-anthologized tale is probably the immediate source, there are many other available ones which include the three essential story elements: grave, wager, & knife. The oldest printed version in English to be found dates from 1825 when it appeared in the pages of The Terrific Register. The story has been recently reprinted in the compilation Tales From The Terrific Register: Book of Ghosts (2010) pp. 107-112. The setting is Westminster Abbey around the year 1735 when the Henry VII Chapel Vault has been opened for the admission of the Queen's body. (The Queen must be George II's consort Caroline of Ansbach who died on 20 November 1737 and is the only Queen buried in the vault anywhere near the year 1735). The only significant change is that the wielder of the knife survives his ordeal and relates much of the tale in the first person. It should be noted that The Terrific Register was notorious for publishing fiction as fact and that it was probably a well-known legend by 1825.