The chocolate didn’t go bad. In fact, it takes an exceptionally long time for chocolate to expire. You have 6-8 months to consume milk and white chocolate after you open it, and even one year if the chocolate is still unopened and in its original wrapper. When it comes to dark chocolate, the real expiration time gets postponed even more: you can keep dark chocolate in your house for up to ten years, and it will still be safe to eat!
Your chocolate can develop a white surface for two distinctive reasons: humidity (Sugar Bloom) or bad tempering/temperature fluctuations (Fat Bloom).
Sugar bloom happens when water comes into contact with the chocolate. If the chocolate was placed in the fridge or it has spent some time in a place with a high humidity level, sugar bloom will most likely occur. The white stuff you see on the surface is condensation: the chocolate absorbs the water, causing the sugar to dissolve, and when the water evaporates, the sugar re-solidifies in small crystals, causing a layer of dried sugar to appear on the surface. To say it professionally, the sugar has crystallized.
Fat bloom has to do with cocoa butter instead (the fatty part of chocolate). It occurs when the cocoa butter loses its place inside the chocolate because it was either tempered badly (or not tempered at all), or it was exposed to warm temperatures: the cocoa butter melts, separates from the other ingredients and rises to the surface.
You now understand that, whether it’s sugar or fat bloom, the chocolate hasn’t gone bad. It has just changed its internal ideal structure, with the sugar or the cocoa butter that stopped being in their designated positions and got all over the place.
To avoid sugar and fat bloom, it’s good practice to always store your chocolate in a dark (far away from any light source), cool (not warm and not cold) and dry places like the pantry or a drawer. This way the chocolate won’t suffer any change in temperature.