Coded caching systems can facilitate traffic offloading from base stations and content sharing between content providers and content requesters via device- to-device (D2D) communications. In particular, dividing content items into mul-tiple pieces not only can enable the possibility of decreasing transmission delay and energy consumption, but also can contribute to secrecy enhancement since potential social outcasts can decode the content item only if they can obtain enough pieces. In this work, the tradeoff problem between content sharing efficiency and secure transmission in coded caching systems is investigated. First, to maximize the caching hit ratio with secrecy outage constraints, a joint optimization problem considering coding parameters, content placement, and power allocation is formulated. Further, a lower bound on the caching hit ratio and a upper bound on the secrecy outage probability are derived to simplify the original optimization problem. Numerical results demonstrate the effectiveness of the proposed scheme.