كتاب الإمارة
33  
The Book on Government
(18)
Chapter: It is recommended for the army to swear allegiance to the ruler when intending to fight, and an account of Bay'at Ar-Ridwan beneath the tree
(18)
باب اسْتِحْبَابِ مُبَايَعَةِ الإِمَامِ الْجَيْشَ عِنْدَ إِرَادَةِ الْقِتَالِ وَبَيَانِ بَيْعَةِ الرِّضْوَانِ تَحْتَ الشَّجَرَةِ
Sahih Muslim 1860 a

It has been narrated on the authority of Yazid b. Abu Ubaid (the freed slave of Salama b. al-Akwa') who said:

1 asked Salama as to what effect he had sworn fealty to the Messenger of Allah (ﷺ) on the Day of Hudaibiya. He said: To the effect that we will die fighting.
وَحَدَّثَنَا قُتَيْبَةُ بْنُ سَعِيدٍ، حَدَّثَنَا حَاتِمٌ، - يَعْنِي ابْنَ إِسْمَاعِيلَ - عَنْ يَزِيدَ بْنِ أَبِي، عُبَيْدٍ مَوْلَى سَلَمَةَ بْنِ الأَكْوَعِ قَالَ قُلْتُ لِسَلَمَةَ عَلَى أَىِّ شَىْءٍ بَايَعْتُمْ رَسُولَ اللَّهِ صلى الله عليه وسلم يَوْمَ الْحُدَيْبِيَةِ قَالَ عَلَى الْمَوْتِ ‏.‏
Reference : Sahih Muslim 1860a
In-book reference : Book 33, Hadith 118
USC-MSA web (English) reference : Book 20, Hadith 4590
  (deprecated numbering scheme)