I had performed mediocre in my core subjects during my PhD, is it justified for me to think about a future in academia? I am a final year PhD in mechanical engineering. I did average/below average in my core courses, during my undergraduate, and PhD coursework. My research area involves using finite element and volume methods to model material and fluid flow. I had got B-'s and C's in my mathematics, mechanics, numerical methods courses during my undergrad and grad school. I love the subjects, but I am not good at them. I decided to go for PhD in them because the research area fascinated me.

I really enjoyed working on my research during my PhD and was quite productive. My research was not mathematically intensive and focused more on developing optimization procedures while making use of existing numerical tools. My advisor, my committee think I did a fair job on the research projects I worked on.

However, since my goal eventually is to be in academia, I feel that my poor academic performance is an indicator of not pursuing a career in university academic environment. I am confident that I can do good independent research.  And I like teaching, though, I did not get any opportunity to teach the core courses during my phd. I am worried that considering my poor background, I will fail to teach a core course when given the opportunity to do so.

Is it justified for me to think about a future in academia in a university setting?
There are a lot of reasons for struggling though coursework and you don't really give enough information to make any clear recommendation. But I can give perspective at least. 

One problem you have is that you haven't much experience teaching, so it is hard to guess how you would do at it. But some people who struggle with a course can teach it well and others who breezed though it can't. The reason for that is that the "struggler" recognizes (perhaps) the hard parts and can help others past them, while the "breezer" just doesn't understand why others don't just find it as easy as s/he did. Some people do some things naturally and without effort and find it hard to focus on the parts that others don't get and provide the insight to get past the problems. 

Many new teachers holding PhDs don't understand that the students in their classes are not like themselves. Only a tiny fraction of their students will have the same motivation and the same sort of motivation that they do. 

A second, orthogonal, idea is that your learning doesn't end when your schooling does. You say you "aren't good" at some subjects. Well that isn't necessarily a permanent condition. Moreover, your standards may be so high that you find it difficult to measure up to them yourself. So your not good may be someone else's good enough. 

Teaching, like research, is hard work. It depends on understanding the students as much as understanding the "material". Your students can learn if you give them meaningful work to spark their interest and build their skill. 

So, while I can't provide an answer, I suggest that you don't give up easily and think deeply about the implications of your choices. Independent research is very difficult. Having the collaboration environment provided by a university (or industrial lab) is a great help.