You will not be able to lose your guarantee. It's legal when you want to root and install version 4.1 from XDA developers website on Samsung Galaxy S2 phone. https://drivingmad.io
Rooting your Samsung Galaxy S2 and installing a custom ROM (like Android 4.1) is legal in most countries but may void your warranty. Check your local laws and warranty terms.For more details, see https://nullsbrawlls.com/