Most people I have met -myself included- usually described self-assurance as something they wish they had. Just like if self-confidence was something that one had been given once and for all. Set it and forget it.
I have come to realize that it is actually much more dynamic. Confidence is earned rather than being inherited. And you never really *obtain* it. Instead, you must exercise it, constantly. I vividly remember when I started to learn programming, reading books and tutorials, surfing my excitement and growing passion just like if it was a sea of hot chocolate. But there was also that ramping shadow hidden in the waves, the one that tear you down from the inside, whispering to my ears that I would simply never be good enough in that field to do anything meaningful to be recognized. It felt important to me at the time, to idealize that one day I would come up with a ground-breaking idea that would bring me recognition, from others and myself. Idealize is the keyword here, as I was spending more time researching and learning that actually producing anything. It all changed when I started putting crappy stuff out in the world. When I started talking about it, with other passionate folks around me at work, at parties, online. Engaging in activities you love, making them real through dialogue and projects was in hindsight a key factor in helping me feeling more grounded with myself.
Is that all though? Isn't self-confidence more like the result of others judgements on our abilities? I used to feel that way, searching validation from my peers on meaningful occasions. I now tend to consider that others may help you gardening but don't make them responsible for growing your tree. At the end of the day, it is a matter of trust between you and yourself. And the three things trust require in my opinion are sincerity, commitment and acts. Just like some contract that you pass with your inner self, shaking your hands, accepting your forces and weaknesses sincerely and committing to make good use of them for yourself and the ones you care about. That's also something worth adding, that I realized when my daughter was born: feeling loved makes you strong and loving makes you brave (unknown author, happy to get the reference if you have it).
So eventually it really resembles a muscle: it must be worked on constantly to improve, overcoming challenges and obstacles of increasing difficulty. Others can help you but ultimately you're the one that needs to commit the effort. And it can get injured. And that's okay. Because with enough time and efforts, it can recover.