The obligation of obeying leaders in matters that do not involve sin, but it is forbidden to obey them in sinful matters Sahih Muslim 1839 b

Arabic hadith text
وَحَدَّثَنَاهُ زُهَيْرُ بْنُ حَرْبٍ، وَمُحَمَّدُ بْنُ الْمُثَنَّى، قَالاَ حَدَّثَنَا يَحْيَى، وَهُوَ الْقَطَّانُ ح وَحَدَّثَنَا ابْنُ نُمَيْرٍ، حَدَّثَنَا أَبِي كِلاَهُمَا، عَنْ عُبَيْدِ اللَّهِ، بِهَذَا الإِسْنَادِ مِثْلَهُ
Translation

This hadith has been transmitted on the authority of 'Ubaidullah.