Yes, legal to buy and carry in Germany. It's sold as a repellent against dangerous animals - Tierabwehrspray. A number of colleagues have been caught out at UK airports...many more have sailed through security with one in their handbag oblivious to the fact it's illegal (but had their yoghurt confiscated).